library(knitr)
setwd("/home/jmoy001/Documents/Presentation")
read_chunk("Presentation_DSC424.R")
knitr::opts_chunk$set(echo = TRUE)

Load Libraries

#load libraries
library(foreign)  # Allows us to read spss files!
require(stats)
require(corrplot)
library(dplyr)
library(tidyr)
require(curl)
require(rio)
require(car)
require(glmnet)
require(rpart)
require(shinyFiles)
require(gvlma)
require(data.table)
require(ggplot2)
require(factoextra)
require(FactoMineR)
library(psych)

Table of Contents

  1. Why is Multicollinearity bad?
  2. Solutions towards overfitting?
  1. Regularized Regression
  2. PCA
  3. Factor Analysis

Interpreting Regression Summary

hbat = read.spss("/home/jmoy001/Documents/Presentation/DSC_424_Material/HBAT.sav", to.data.frame=T,use.value.labels=FALSE)
colnames(hbat)
##  [1] "id"  "x1"  "x2"  "x3"  "x4"  "x5"  "x6"  "x7"  "x8"  "x9"  "x10"
## [12] "x11" "x12" "x13" "x14" "x15" "x16" "x17" "x18" "x19" "x20" "x21"
## [23] "x22" "x23"
attr(hbat,'variable.labels')
##                                  id                                  x1 
##                                "ID"                "X1 - Customer Type" 
##                                  x2                                  x3 
##                "X2 - Industry Type"                    "X3 - Firm Size" 
##                                  x4                                  x5 
##                       "X4 - Region"          "X5 - Distribution System" 
##                                  x6                                  x7 
##              "X6 - Product Quality"        "X7 - E-Commerce Activities" 
##                                  x8                                  x9 
##            "X8 - Technical Support"         "X9 - Complaint Resolution" 
##                                 x10                                 x11 
##                 "X10 - Advertising"                "X11 - Product Line" 
##                                 x12                                 x13 
##            "X12 - Salesforce Image"         "X13 - Competitive Pricing" 
##                                 x14                                 x15 
##           "X14 - Warranty & Claims"                "X15 - New Products" 
##                                 x16                                 x17 
##             "X16 - Order & Billing"           "X17 - Price Flexibility" 
##                                 x18                                 x19 
##              "X18 - Delivery Speed"                "X19 - Satisfaction" 
##                                 x20                                 x21 
##         "X20 - Likely to Recommend"          "X21 - Likely to Purchase" 
##                                 x22                                 x23 
##              "X22 - Purchase Level" "X23 - Consider Strategic Alliance"
#Change Variable Names
colnames(hbat) <- attr(hbat,'variable.labels')
colnames(hbat)
##  [1] "ID"                               
##  [2] "X1 - Customer Type"               
##  [3] "X2 - Industry Type"               
##  [4] "X3 - Firm Size"                   
##  [5] "X4 - Region"                      
##  [6] "X5 - Distribution System"         
##  [7] "X6 - Product Quality"             
##  [8] "X7 - E-Commerce Activities"       
##  [9] "X8 - Technical Support"           
## [10] "X9 - Complaint Resolution"        
## [11] "X10 - Advertising"                
## [12] "X11 - Product Line"               
## [13] "X12 - Salesforce Image"           
## [14] "X13 - Competitive Pricing"        
## [15] "X14 - Warranty & Claims"          
## [16] "X15 - New Products"               
## [17] "X16 - Order & Billing"            
## [18] "X17 - Price Flexibility"          
## [19] "X18 - Delivery Speed"             
## [20] "X19 - Satisfaction"               
## [21] "X20 - Likely to Recommend"        
## [22] "X21 - Likely to Purchase"         
## [23] "X22 - Purchase Level"             
## [24] "X23 - Consider Strategic Alliance"
#pull numeric columns only, remove dummy variable columns
hbatNumeric = hbat[, c(20, 7:19)]

##Correlation Plot
##Without dependent variable
#copy same table
hbatNumeric_Independent <- hbatNumeric

#remove dependent variable
X19_Satisfaction <-hbatNumeric_Independent$`X19 - Satisfaction`
hbatNumeric_Independent$`X19 - Satisfaction` <- NULL
corrplot(cor(hbatNumeric_Independent), method="number")

##Remove correlations greater than .70
#focus on upper triangle
pcor <- cor(hbatNumeric_Independent, use = "complete.obs")
pcor[upper.tri(pcor)] <- 0
diag(pcor) <- 0
upper.df <-hbatNumeric_Independent[,!apply(pcor,2,function(x) any(x > abs(0.7)))]
upper.df <- cbind(X19_Satisfaction,upper.df)


#regression Upper.df
fullFit_Upper = lm(X19_Satisfaction ~ ., data=upper.df)

#Regression results
summary(fullFit_Upper)
## 
## Call:
## lm(formula = X19_Satisfaction ~ ., data = upper.df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.47670 -0.25214  0.03872  0.36476  1.39470 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 -2.083746   1.179992  -1.766   0.0808 .  
## `X6 - Product Quality`       0.413249   0.054872   7.531 3.73e-11 ***
## `X10 - Advertising`         -0.054467   0.066878  -0.814   0.4176    
## `X11 - Product Line`         0.292188   0.279904   1.044   0.2993    
## `X12 - Salesforce Image`     0.592062   0.074166   7.983 4.42e-12 ***
## `X13 - Competitive Pricing` -0.067706   0.050891  -1.330   0.1867    
## `X14 - Warranty & Claims`   -0.008860   0.080303  -0.110   0.9124    
## `X15 - New Products`        -0.001152   0.041647  -0.028   0.9780    
## `X17 - Price Flexibility`    0.223775   0.286106   0.782   0.4362    
## `X18 - Delivery Speed`       0.196462   0.539303   0.364   0.7165    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6081 on 90 degrees of freedom
## Multiple R-squared:  0.7634, Adjusted R-squared:  0.7397 
## F-statistic: 32.26 on 9 and 90 DF,  p-value: < 2.2e-16

-Call: Provides the formula that you’ve inputted into the model

-Residuals: Five number summary of the residuals Residual = actual - predicted Shows the distribution of error

-Coefficients:

Estimate: Intercept: Average value of Y when x=0 Cannot interpret this, doesnt make sense. ex) Suggests that when all explanatory variables are equal to zero, satisfaction is -2.08.

Betas: Shows us the numerical relationship between the variable and dependent variable (Practical Significance) Ex) X6, X10, X11,…., X18

Interpretable: A one unit increase in Product Quality, there is an expected change in Satisfaction by .41.

Std. Error: Estimate of Variability

Since this is an estimate of a coefficient, there is some error. Standard error is the variability that we would expect if sampling is done Ex) Analysis done at different periods

t value: Ratio of the Estimate/Standard Error How big is my estimate relative to my error?

T value comes with a p value. Most common when checking whether a variable is significant or not.

p value: Check whether a variable is statistically significant or not. ex) What is the probability that the variable is equal to 0 (statistically insignificant)

Recall Hypothesis Testing Null Hypothesis: H0) There is no difference Alt Hypothesis: H1) There is a difference

Usually test a p-value against an alpha level (.05 is the standard) Alpha can be .01, .05, .1. How much error will you accept for the variable?

Residual Standard Error: AKA Root Mean Squared Error (RMSE), Regression Standard Error, etc

Shows how poorly the model does at predicting Y values in the data on average. The smaller the RMSE, the better

Multiple R-Squared: Percentage of variance explained of the dependent variable by the model. In other words, how well does your model fit the dependent variable

Ideally, want multiple R-squared to be high. In some fields, .2 and .3 are considered high. But ultimately, the field of application you are using regression in will determine the adequate level of Multiple r-squared.

Adjusted R-Squared: By adding more variables to your model, it will increase the multiple R-squared, whether it is useful or useless variables. Adjusted R-Squared will penalize you for adding useless variables to your model.

You cannot interpret multiple R-squared the same as adjusted R-squared.

knitr::include_graphics("adjusted_R_vs_multiple_R.png")

Adjusted R-squared will always be lower than multiple R-squared, so adding a useless variable to the model, will make that difference greater.

F-Statistic: Meaures significance of the overall model: Ratio of the model performance / error Higher the F-statistic, the better

P-value: Shows the overall signifiance of the model

The big question, is this a good regression model???

The Four Assumptions for a Good Regression Model

  1. Normality of the error distribution (Residuals should be normally distributed)

  2. Linear relationship between the dependent and independent variable

  3. Statistical independence of the errors (No Multicollinearity)

  4. Homoscedasticity (Constant Variance)

par(mfrow=c(2,2))  # set 2 rows and 2 column plot layout
plot(fullFit_Upper)

By plotting the regression model, it generates 4 graphs for us.

Assumption 4 Test: Residuals vs fitted/predicted: There should not be any patterns (random) and red line should be fairly flat. Variability is about the same for different values of X (constant Variance)

Assumption 1 Test: Normal Q-Q (Quantile-Quantile): If the residuals are approximately normally distributed, then most of the points should be relatively on the line. Some deviation is expected near the ends, but deviations should be small

Additional tests for normality of residuals:

Scale-Location: ensure our residuals are random, not having a pattern to them. If you see a cheese wedge, then we have variability, may need to do transformations or use another type of regression.

Residuals vs Leverage: may have outliers, take them out if they are not influential. Depends on application though. Ex) Medical, might indicate a side effect Dotted line, anything pass that shows influential outiers. If we take outliers out, will change data.

Function to check assumptions automatically

gvlma(fullFit_Upper)
## 
## Call:
## lm(formula = X19_Satisfaction ~ ., data = upper.df)
## 
## Coefficients:
##                 (Intercept)       `X6 - Product Quality`  
##                   -2.083746                     0.413249  
##         `X10 - Advertising`         `X11 - Product Line`  
##                   -0.054467                     0.292188  
##    `X12 - Salesforce Image`  `X13 - Competitive Pricing`  
##                    0.592062                    -0.067706  
##   `X14 - Warranty & Claims`         `X15 - New Products`  
##                   -0.008860                    -0.001152  
##   `X17 - Price Flexibility`       `X18 - Delivery Speed`  
##                    0.223775                     0.196462  
## 
## 
## ASSESSMENT OF THE LINEAR MODEL ASSUMPTIONS
## USING THE GLOBAL TEST ON 4 DEGREES-OF-FREEDOM:
## Level of Significance =  0.05 
## 
## Call:
##  gvlma(x = fullFit_Upper) 
## 
##                       Value p-value                Decision
## Global Stat        2.477927  0.6486 Assumptions acceptable.
## Skewness           2.342454  0.1259 Assumptions acceptable.
## Kurtosis           0.090930  0.7630 Assumptions acceptable.
## Link Function      0.038485  0.8445 Assumptions acceptable.
## Heteroscedasticity 0.006058  0.9380 Assumptions acceptable.

Have all the assumptions been verified?

Not quite, 3. Statistical independence of the errors (No Multicollinearity)

Variance Inflation Factor - Metric computed for every X variable that goes into the model. If the VIF of a variable is high, it means the information in the variable is already explained by other X variables present in the given model (more redundant information).

Hence, the lower the VIF, the better.

In the background: VIF function runs auxiliary regressions for each independent variable and records the R-squared to be calculated by VIF formula below.

knitr::include_graphics("VIF_Formula.png")

Rule of Thumb:

1: No issues of multicollinearity

5-10: moderate issues of multicollinearity

10-above: Major issues of multicollinearity

Note, in some contexts, a VIF of 2 could should major issues of multicollinearity

vif(fullFit_Upper)
##      `X6 - Product Quality`         `X10 - Advertising` 
##                    1.571683                    1.520879 
##        `X11 - Product Line`    `X12 - Salesforce Image` 
##                   36.289485                    1.693475 
## `X13 - Competitive Pricing`   `X14 - Warranty & Claims` 
##                    1.655352                    1.160201 
##        `X15 - New Products`   `X17 - Price Flexibility` 
##                    1.035222                   31.876694 
##      `X18 - Delivery Speed` 
##                   42.004599

Why is multi-collinearity bad???

Inflation of the Betas - may not make sense when interpreting Ex)Inaccuracies in the computation of the betas

Change in the sign of the betas: Ex)Positive correlation when using a corr matrix, but negative correlation in regression model)

#Symptoms of Multicollinearity

#Includes Dependent Variable
corrplot(cor(upper.df), method="number")

#first column only: Correlation of independent variables with dependent variable
cor(upper.df)[,1]
##          X19_Satisfaction      X6 - Product Quality 
##                1.00000000                0.48632500 
##         X10 - Advertising        X11 - Product Line 
##                0.30466947                0.55054594 
##    X12 - Salesforce Image X13 - Competitive Pricing 
##                0.50020531               -0.20829569 
##   X14 - Warranty & Claims        X15 - New Products 
##                0.17754482                0.07089830 
##   X17 - Price Flexibility      X18 - Delivery Speed 
##                0.05595266                0.57704227
#reference from earlier, regression summary 
summary(fullFit_Upper)
## 
## Call:
## lm(formula = X19_Satisfaction ~ ., data = upper.df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.47670 -0.25214  0.03872  0.36476  1.39470 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 -2.083746   1.179992  -1.766   0.0808 .  
## `X6 - Product Quality`       0.413249   0.054872   7.531 3.73e-11 ***
## `X10 - Advertising`         -0.054467   0.066878  -0.814   0.4176    
## `X11 - Product Line`         0.292188   0.279904   1.044   0.2993    
## `X12 - Salesforce Image`     0.592062   0.074166   7.983 4.42e-12 ***
## `X13 - Competitive Pricing` -0.067706   0.050891  -1.330   0.1867    
## `X14 - Warranty & Claims`   -0.008860   0.080303  -0.110   0.9124    
## `X15 - New Products`        -0.001152   0.041647  -0.028   0.9780    
## `X17 - Price Flexibility`    0.223775   0.286106   0.782   0.4362    
## `X18 - Delivery Speed`       0.196462   0.539303   0.364   0.7165    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6081 on 90 degrees of freedom
## Multiple R-squared:  0.7634, Adjusted R-squared:  0.7397 
## F-statistic: 32.26 on 9 and 90 DF,  p-value: < 2.2e-16
#Reference 
  • High error

  • Big difference between the adjusted R squared and multiple R Squared

  • Overfitting (symptom of multicollinearity) - Model created with training data has a high accuracy when applied to the training data, but low accuracy when applied to test data.

Causes of overfitting: Data has too few data points for the number of parameters and features (Summit #3- Churn data) Too many features that will make the model more complex

Solutions towards overfitting:

Cross validation: Instead of separating your data into a training and test set, partition the data into k folds. 1 fold is set aside for testing and the remaining folds are used for training. Then would average out the accuracy for each train/test data split. If the training accuracy from one model (train/test split) is similar to the cross validation model, there is no overfitting. However, if there is a big difference, this is due to overfitting.

Pruning using Decision Trees: Idea is to classify the data into trees by variable importance. Ex) Depending on the outlook(sunny, overcast, rain), was the most important variable in deciding whether or not you will go play tennis outside. Shows the probability for each outlook and shows the next variable(temperature) of importance until all data has been classified. Model will be way too complex. To avoid overfitting, prune the tree(stop splitting) when tree is no long statistically significant.

Regularized Regression: Reduces overfitting by adding a penalty for model complexity or extreme parameter values (high betas due to multicollinearity). The penalty parameter is lambda, where if the value is too low, it wont do anything to treat it as an Ordinary Least Squares (OLS) Regression and if too high, will add too much weight and will underfit the model.

Three types of Regularized Regression:

  1. Lasso Regression - Stands for Least Absolute Shrinkage and Selection Operator. Uses L1 normalization and adds the absolute value of magnitude of the coefficient as a penalty term to the loss function. Also performs feature selection by shinking the betas of the less important features to zero.

  2. Ridge Regression - Uses L2 normalization and adds a squared magnitude of coefficient as a penalty term to the loss function. Ridge regression does not offer feature selection like Lasso does, but by viewing the graph of lambda against the Mean Squared Error (MSE), allows you to select the lambda used to optimize the model by choosing the smallest MSE.

  3. Elastic Net - Combination of Ridge and Lasso Regression

knitr::include_graphics("Lasso_vs_Ridge_Variance_Tradeoff.png")

Another thing that comes into play with model building is parsimony. Want to have a small number of variables in the model. Because as we increase the number of variables in the model (hence the model complexity), will be increasing variance and increasing prediction error.

knitr::include_graphics("Lasso_vs_Ridge.png")

Any betas inside the circle (constraint region) is fine. Lasso has that shape (diamond) since unimportant features are penalized to 0 (lie on the axis)

#Ridge and Lasso Regression
hbatNumeric_Independent <- hbatNumeric
X19_Satisfaction <-hbatNumeric_Independent$`X19 - Satisfaction`
hbatNumeric_Independent$`X19 - Satisfaction` <- NULL


#Lasso
#alpha=1
#must read in x (independent variables) as matrix
lasso_model <- cv.glmnet(as.matrix(hbatNumeric_Independent), X19_Satisfaction, lambda=10^seq(4,-1,-.1), alpha=1)

#dotted line shows optimal lambda values
#Either 1 standard deviation above the best or the best lambda value
plot(lasso_model)

#log function to match plot view
Optimal_Lambda <- lasso_model$lambda.1se
Lasso_coefficients <- lasso_model$glmnet.fit$beta[ , lasso_model$glmnet.fit$lambda == Optimal_Lambda]

#Ridge
#alpha=0
#must read in x (independent variables) as matrix
ridge_model <- cv.glmnet(as.matrix(hbatNumeric_Independent), X19_Satisfaction, lambda=10^seq(4,-1,-.1), alpha=0)

#dotted line shows optimal lambda values
#Either 1 standard deviation above the best or the best lambda value
plot(ridge_model)

#log function to match plot view
Optimal_Lambda <- ridge_model$lambda.1se
Ridge_coefficients <- ridge_model$glmnet.fit$beta[ , ridge_model$glmnet.fit$lambda == Optimal_Lambda]


#ElasticNet
#alpha=.5
#must read in x (independent variables) as matrix
elastic_net_model <- cv.glmnet(as.matrix(hbatNumeric_Independent), X19_Satisfaction, lambda=10^seq(4,-1,-.1), alpha=0.5)

#dotted line shows optimal lambda values
#Either 1 standard deviation above the best or the best lambda value
plot(elastic_net_model)

#log function to match plot view
Optimal_Lambda <- elastic_net_model$lambda.1se
Elastic_net_coefficients <- elastic_net_model$glmnet.fit$beta[ , elastic_net_model$glmnet.fit$lambda == Optimal_Lambda]


coef_df <- data.table(Features = names(Lasso_coefficients),
                      Lasso= Lasso_coefficients,
                   Ridge= Ridge_coefficients,
                   Elastic_Net = Elastic_net_coefficients)

#wide to long
coef_df <- coef_df %>%
  tidyr::gather(Regularized_Regression, value, Lasso:Elastic_Net)

ggplot(coef_df, aes(Features, value, fill=Regularized_Regression)) + 
  coord_flip() + geom_bar(stat='identity') + 
  #split by test
  facet_wrap(~ Regularized_Regression) + 
  #remove legend
  guides(fill=FALSE)

Ways to Handle Multicollinearity?

Regularized Regression - Ridge, Lasso, and Elastic Net

Principal Component Analysis

knitr::include_graphics("PCA_Intro.png")

Dimensionality reductions - Want to keep as many features as possible to be explained in components (grouped features). Reduce the amount of variables in your dataset to a few principal components that explains the variance.

Latent Variable Discovery - Want to interpret components. Ex) Lots of independent variables are highly correlated. Can we group the variables into their own distinct component that is not correlated with other components and is interpretable?

Purpose of PCA stems from Variance

knitr::include_graphics("PCA_Variance.png")

The total variance is summed up on the diagonals of the covariance matrix. A ratio between the components and the overall sum of the variance shows how much variance does each component explain.

Main Idea: Have a lot of multicollinearity in the data. Trying to keep as much variables as possible by putting them into smaller components, to reduce multicollinearity.

knitr::include_graphics("PCA_Correlated_Uncorrelated.png")

Taking variables that are correlated and rotating it so that it is uncorrelated on the worlds axis.

knitr::include_graphics("PCA_Rotation.PNG")

By rotating the axis, it redistributes the variance and makes the loadings much easier to interpret.

In summary, PCA replaces original variables with new variables (Principal Components) that are orthogonal (zero covariance) and have variances (eigen values) in decreasing order.

HBAT Example

Correlation Plot to see principal component groupings
library(psych)
options("scipen"=100, "digits"=5)


#see what the p values are for each bi-variate relationship
#independent variables only
MCorrTest = corr.test(hbatNumeric[, 2:14], adjust="none")
M = MCorrTest$p
MTest = ifelse(M < .01, T, F)


colSums(MTest) - 1  # We have to subtract 1 for the diagonal elements (self-correlation)
##       X6 - Product Quality X7 - E-Commerce Activities 
##                          3                          3 
##     X8 - Technical Support  X9 - Complaint Resolution 
##                          2                          4 
##          X10 - Advertising         X11 - Product Line 
##                          4                          7 
##     X12 - Salesforce Image  X13 - Competitive Pricing 
##                          5                          5 
##    X14 - Warranty & Claims         X15 - New Products 
##                          2                          0 
##      X16 - Order & Billing    X17 - Price Flexibility 
##                          4                          9 
##       X18 - Delivery Speed 
##                          6
#shows the amount of variables that are correlated with each other
#run a PCA or factor analysis on these variables to remove the multicollinearity by removing redundant columns

### NO POINT OF PCA IF THERE IS NO MULTICOLLINEARITY. Purpose of PCA is to group variables into principal components

#if we do a PCA, component will drag all variables

# We remove two columns, the first (x15 = column 11) is not correlated with anything else
# The second (x17 = column 13) is correlated with too many other variables. It might create one component (HARD TO EXPLAIN!)
# keep x14 because it has relationship with other variables and could fall into another component

#1 taken out too since it is our dependent variable, customer satisfaction
#17 is taken out because it might create 1 component, because it is related to everything else, may push the 9
#related variables to 1 component vs. being spread out to multiple components

#remove those 3 columns
hbatReduced = hbatNumeric[, -c(1, 11, 13)]

3 Methods to check for the # of components to have in your model

Scree Plot

p = prcomp(hbatReduced, center=T, scale=T)
#scale=T, using correlation matrix. If same units, scale=F and using co-variance matrix

plot(p)
#need to add horizontal y=1 to see which eigen values are greater than 1
abline(1, 0)

#4 principal components

Knee of Scree Plot

#Number of components where Eigenvalue evens out
plot(p)

# 4 principal components

Cumalative Variance (60-80% if Latent Variable Discovery)

summary(p)
## Importance of components:
##                          PC1   PC2   PC3    PC4    PC5    PC6    PC7
## Standard deviation     1.851 1.597 1.300 1.0424 0.7807 0.7429 0.6337
## Proportion of Variance 0.312 0.232 0.154 0.0988 0.0554 0.0502 0.0365
## Cumulative Proportion  0.312 0.543 0.697 0.7960 0.8514 0.9015 0.9380
##                           PC8    PC9   PC10    PC11
## Standard deviation     0.4969 0.4512 0.3645 0.31373
## Proportion of Variance 0.0225 0.0185 0.0121 0.00895
## Cumulative Proportion  0.9605 0.9790 0.9910 1.00000
# 3-4 principal components

Test # of components and interpretability of PCA

p2 = psych::principal(hbatReduced, covar=FALSE, rotate="varimax", nfactors=4, scores=TRUE, oblique.scores=TRUE)

p2
## Principal Components Analysis
## Call: psych::principal(r = hbatReduced, nfactors = 4, rotate = "varimax", 
##     covar = FALSE, scores = TRUE, oblique.scores = TRUE)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                              RC1   RC2   RC3   RC4   h2    u2 com
## X6 - Product Quality        0.00 -0.01 -0.03  0.88 0.77 0.232 1.0
## X7 - E-Commerce Activities  0.06  0.87  0.05 -0.12 0.78 0.223 1.1
## X8 - Technical Support      0.02 -0.02  0.94  0.10 0.89 0.107 1.0
## X9 - Complaint Resolution   0.93  0.12  0.05  0.09 0.88 0.119 1.1
## X10 - Advertising           0.14  0.74 -0.08  0.01 0.58 0.424 1.1
## X11 - Product Line          0.59 -0.06  0.15  0.64 0.79 0.213 2.1
## X12 - Salesforce Image      0.13  0.90  0.08 -0.16 0.86 0.141 1.1
## X13 - Competitive Pricing  -0.09  0.23 -0.25 -0.72 0.64 0.359 1.5
## X14 - Warranty & Claims     0.11  0.05  0.93  0.10 0.89 0.108 1.1
## X16 - Order & Billing       0.86  0.11  0.08  0.04 0.77 0.234 1.1
## X18 - Delivery Speed        0.94  0.18  0.00  0.05 0.91 0.086 1.1
## 
##                        RC1  RC2  RC3  RC4
## SS loadings           2.89 2.23 1.86 1.77
## Proportion Var        0.26 0.20 0.17 0.16
## Cumulative Var        0.26 0.47 0.63 0.80
## Proportion Explained  0.33 0.26 0.21 0.20
## Cumulative Proportion 0.33 0.59 0.80 1.00
## 
## Mean item complexity =  1.2
## Test of the hypothesis that 4 components are sufficient.
## 
## The root mean square of the residuals (RMSR) is  0.06 
##  with the empirical chi square  39.02  with prob <  0.0018 
## 
## Fit based upon off diagonal values = 0.97
#Ideally want a low RMSE and p value less than .05
#4 components have an error rate of .01%


#Loading - correlation between the factor and the variable. Interpret them as beta coefficients in PCA
#Ex) A high loading suggests a variable has a high influence within that factor

#Scores - Loadings multiplied by variable gives the formula of the score.
#Ex) The variables that makes up that component

#Purpose of rotation?
#Rotate components to redistributes the variance and makes the loadings easier to interpret.


print(p2$loadings, cutoff=.4, sort=T)
## 
## Loadings:
##                            RC1    RC2    RC3    RC4   
## X9 - Complaint Resolution   0.926                     
## X16 - Order & Billing       0.864                     
## X18 - Delivery Speed        0.938                     
## X7 - E-Commerce Activities         0.871              
## X10 - Advertising                  0.742              
## X12 - Salesforce Image             0.900              
## X8 - Technical Support                    0.939       
## X14 - Warranty & Claims                   0.931       
## X6 - Product Quality                             0.876
## X11 - Product Line          0.591                0.642
## X13 - Competitive Pricing                       -0.723
## 
##                  RC1   RC2   RC3   RC4
## SS loadings    2.893 2.234 1.856 1.774
## Proportion Var 0.263 0.203 0.169 0.161
## Cumulative Var 0.263 0.466 0.635 0.796
#9, 16, 18, 11 are part of component 1
#remember, 11 is called a cross loading because in 2 different areas(could be more). variable should be 1 per component
#instead of asking a cutoff of .4, try asking for a cutoff of .6
print(p2$loadings, cutoff=.6, sort=T)
## 
## Loadings:
##                            RC1    RC2    RC3    RC4   
## X9 - Complaint Resolution   0.926                     
## X16 - Order & Billing       0.864                     
## X18 - Delivery Speed        0.938                     
## X7 - E-Commerce Activities         0.871              
## X10 - Advertising                  0.742              
## X12 - Salesforce Image             0.900              
## X8 - Technical Support                    0.939       
## X14 - Warranty & Claims                   0.931       
## X6 - Product Quality                             0.876
## X11 - Product Line                               0.642
## X13 - Competitive Pricing                       -0.723
## 
##                  RC1   RC2   RC3   RC4
## SS loadings    2.893 2.234 1.856 1.774
## Proportion Var 0.263 0.203 0.169 0.161
## Cumulative Var 0.263 0.466 0.635 0.796
#Cross loadings removed
#Now we would need to be able to create names for the new variables to be interpretable.

PCA Project

df <- read.csv("/home/jmoy001/Documents/Presentation/2016 School Explorer.csv")

#change from N/A to NA
df[df=="N/A"] <- NA


#total
sum(is.na(df))
## [1] 1268
#NA for each variable, hidden because it was 8 pages, but the variables of interest for PCA had no NAs
#sapply(df, function(x) sum(is.na(x)))

#select columns that start with Grade
test <- df %>%
  select(starts_with("Grade"))

#Remove Grades, Grade Low, Grade high
#Grades shows all grades the school has data on
#Grade low is the lowest grade taught, Grade high is the highest grade taught
test <- test[,-c(1,2,3)] 

#remove columns of sum total
final <- test %>%
  select(-contains("All"))


MCorrTest = corr.test(final, adjust="none")

M = MCorrTest$p

MTest = ifelse(M < .01, T, F)

# Amount of variables that are correlated with other variables
colSums(MTest) - 1
##  Grade.3.ELA.4s...American.Indian.or.Alaska.Native 
##                                                  3 
##         Grade.3.ELA.4s...Black.or.African.American 
##                                                 19 
##                Grade.3.ELA.4s...Hispanic.or.Latino 
##                                                 32 
##         Grade.3.ELA.4s...Asian.or.Pacific.Islander 
##                                                 37 
##                             Grade.3.ELA.4s...White 
##                                                 31 
##                       Grade.3.ELA.4s...Multiracial 
##                                                 18 
##        Grade.3.ELA.4s...Limited.English.Proficient 
##                                                 16 
## Grade.3.Math.4s...American.Indian.or.Alaska.Native 
##                                                 13 
##        Grade.3.Math.4s...Black.or.African.American 
##                                                 18 
##               Grade.3.Math.4s...Hispanic.or.Latino 
##                                                 44 
##        Grade.3.Math.4s...Asian.or.Pacific.Islander 
##                                                 39 
##                            Grade.3.Math.4s...White 
##                                                 32 
##                      Grade.3.Math.4s...Multiracial 
##                                                 13 
##       Grade.3.Math.4s...Limited.English.Proficient 
##                                                 17 
##  Grade.4.ELA.4s...American.Indian.or.Alaska.Native 
##                                                  9 
##         Grade.4.ELA.4s...Black.or.African.American 
##                                                 23 
##                Grade.4.ELA.4s...Hispanic.or.Latino 
##                                                 40 
##         Grade.4.ELA.4s...Asian.or.Pacific.Islander 
##                                                 38 
##                             Grade.4.ELA.4s...White 
##                                                 31 
##                       Grade.4.ELA.4s...Multiracial 
##                                                 17 
##        Grade.4.ELA.4s...Limited.English.Proficient 
##                                                 17 
## Grade.4.Math.4s...American.Indian.or.Alaska.Native 
##                                                 15 
##        Grade.4.Math.4s...Black.or.African.American 
##                                                 19 
##               Grade.4.Math.4s...Hispanic.or.Latino 
##                                                 36 
##        Grade.4.Math.4s...Asian.or.Pacific.Islander 
##                                                 39 
##                            Grade.4.Math.4s...White 
##                                                 30 
##                      Grade.4.Math.4s...Multiracial 
##                                                 22 
##       Grade.4.Math.4s...Limited.English.Proficient 
##                                                 19 
##  Grade.5.ELA.4s...American.Indian.or.Alaska.Native 
##                                                  6 
##         Grade.5.ELA.4s...Black.or.African.American 
##                                                 20 
##                Grade.5.ELA.4s...Hispanic.or.Latino 
##                                                 34 
##         Grade.5.ELA.4s...Asian.or.Pacific.Islander 
##                                                 31 
##                             Grade.5.ELA.4s...White 
##                                                 25 
##                       Grade.5.ELA.4s...Multiracial 
##                                                 12 
##        Grade.5.ELA.4s...Limited.English.Proficient 
##                                                 16 
## Grade.5.Math.4s...American.Indian.or.Alaska.Native 
##                                                  9 
##        Grade.5.Math.4s...Black.or.African.American 
##                                                 19 
##               Grade.5.Math.4s...Hispanic.or.Latino 
##                                                 34 
##        Grade.5.Math.4s...Asian.or.Pacific.Islander 
##                                                 28 
##                            Grade.5.Math.4s...White 
##                                                 28 
##                      Grade.5.Math.4s...Multiracial 
##                                                 13 
##       Grade.5.Math.4s...Limited.English.Proficient 
##                                                 16 
##  Grade.6.ELA.4s...American.Indian.or.Alaska.Native 
##                                                 18 
##         Grade.6.ELA.4s...Black.or.African.American 
##                                                 44 
##                Grade.6.ELA.4s...Hispanic.or.Latino 
##                                                 38 
##         Grade.6.ELA.4s...Asian.or.Pacific.Islander 
##                                                 40 
##                             Grade.6.ELA.4s...White 
##                                                 34 
##                       Grade.6.ELA.4s...Multiracial 
##                                                 27 
##        Grade.6.ELA.4s...Limited.English.Proficient 
##                                                 16 
## Grade.6.Math.4s...American.Indian.or.Alaska.Native 
##                                                 15 
##        Grade.6.Math.4s...Black.or.African.American 
##                                                 41 
##               Grade.6.Math.4s...Hispanic.or.Latino 
##                                                 42 
##        Grade.6.Math.4s...Asian.or.Pacific.Islander 
##                                                 44 
##                            Grade.6.Math.4s...White 
##                                                 34 
##                      Grade.6.Math.4s...Multiracial 
##                                                 27 
##       Grade.6.Math.4s...Limited.English.Proficient 
##                                                 25 
##  Grade.7.ELA.4s...American.Indian.or.Alaska.Native 
##                                                  9 
##         Grade.7.ELA.4s...Black.or.African.American 
##                                                 47 
##                Grade.7.ELA.4s...Hispanic.or.Latino 
##                                                 50 
##         Grade.7.ELA.4s...Asian.or.Pacific.Islander 
##                                                 43 
##                             Grade.7.ELA.4s...White 
##                                                 33 
##                       Grade.7.ELA.4s...Multiracial 
##                                                 18 
##        Grade.7.ELA.4s...Limited.English.Proficient 
##                                                 20 
## Grade.7.Math.4s...American.Indian.or.Alaska.Native 
##                                                 22 
##        Grade.7.Math.4s...Black.or.African.American 
##                                                 38 
##               Grade.7.Math.4s...Hispanic.or.Latino 
##                                                 41 
##        Grade.7.Math.4s...Asian.or.Pacific.Islander 
##                                                 43 
##                            Grade.7.Math.4s...White 
##                                                 34 
##                      Grade.7.Math.4s...Multiracial 
##                                                 19 
##       Grade.7.Math.4s...Limited.English.Proficient 
##                                                 23 
##  Grade.8.ELA.4s...American.Indian.or.Alaska.Native 
##                                                 20 
##         Grade.8.ELA.4s...Black.or.African.American 
##                                                 46 
##                Grade.8.ELA.4s...Hispanic.or.Latino 
##                                                 51 
##         Grade.8.ELA.4s...Asian.or.Pacific.Islander 
##                                                 43 
##                             Grade.8.ELA.4s...White 
##                                                 36 
##                       Grade.8.ELA.4s...Multiracial 
##                                                 16 
##        Grade.8.ELA.4s...Limited.English.Proficient 
##                                                 17 
## Grade.8.Math.4s...American.Indian.or.Alaska.Native 
##                                                 18 
##        Grade.8.Math.4s...Black.or.African.American 
##                                                 21 
##               Grade.8.Math.4s...Hispanic.or.Latino 
##                                                 27 
##        Grade.8.Math.4s...Asian.or.Pacific.Islander 
##                                                 32 
##                            Grade.8.Math.4s...White 
##                                                 35 
##                      Grade.8.Math.4s...Multiracial 
##                                                 18 
##       Grade.8.Math.4s...Limited.English.Proficient 
##                                                 25

There are 84 variables that represent the number of students that scored a 4 on their math or ela test of various ethnicities and grade that are highly correlated. Is it possible to use PCA to form components that are interpretable and remove multicollinearity?

Kaiser-Meyer-Olkin (KMO)

KMO tests the sampling adequacy to verify that the data has a large enough sample. (.7 and above)

#how to check for Factorability: Steps to test if PCA can be done with this data.
#pulled KMO and Barlett's test from this website
#http://minato.sip21c.org/swtips/factor-in-R.pdf

#KMO Function
kmo <- function(x)
{
  x <- subset(x, complete.cases(x)) # Omit missing values
  r <- cor(x) # Correlation matrix
  r2 <- r^2 # Squared correlation coefficients
  i <- solve(r) # Inverse matrix of correlation matrix
  d <- diag(i) # Diagonal elements of inverse matrix
  p2 <- (-i/sqrt(outer(d, d)))^2 # Squared partial correlation coefficients
  diag(r2) <- diag(p2) <- 0 # Delete diagonal elements
  KMO <- sum(r2)/(sum(r2)+sum(p2))
  MSA <- colSums(r2)/(colSums(r2)+colSums(p2))
  return(list(KMO=KMO, MSA=MSA))
}


kmo(final)
## $KMO
## [1] 0.81038
## 
## $MSA
##  Grade.3.ELA.4s...American.Indian.or.Alaska.Native 
##                                            0.47835 
##         Grade.3.ELA.4s...Black.or.African.American 
##                                            0.79376 
##                Grade.3.ELA.4s...Hispanic.or.Latino 
##                                            0.82938 
##         Grade.3.ELA.4s...Asian.or.Pacific.Islander 
##                                            0.83692 
##                             Grade.3.ELA.4s...White 
##                                            0.86822 
##                       Grade.3.ELA.4s...Multiracial 
##                                            0.73042 
##        Grade.3.ELA.4s...Limited.English.Proficient 
##                                            0.77530 
## Grade.3.Math.4s...American.Indian.or.Alaska.Native 
##                                            0.55294 
##        Grade.3.Math.4s...Black.or.African.American 
##                                            0.82675 
##               Grade.3.Math.4s...Hispanic.or.Latino 
##                                            0.83905 
##        Grade.3.Math.4s...Asian.or.Pacific.Islander 
##                                            0.86733 
##                            Grade.3.Math.4s...White 
##                                            0.88349 
##                      Grade.3.Math.4s...Multiracial 
##                                            0.71815 
##       Grade.3.Math.4s...Limited.English.Proficient 
##                                            0.84884 
##  Grade.4.ELA.4s...American.Indian.or.Alaska.Native 
##                                            0.56964 
##         Grade.4.ELA.4s...Black.or.African.American 
##                                            0.78795 
##                Grade.4.ELA.4s...Hispanic.or.Latino 
##                                            0.82928 
##         Grade.4.ELA.4s...Asian.or.Pacific.Islander 
##                                            0.84909 
##                             Grade.4.ELA.4s...White 
##                                            0.87812 
##                       Grade.4.ELA.4s...Multiracial 
##                                            0.66052 
##        Grade.4.ELA.4s...Limited.English.Proficient 
##                                            0.81237 
## Grade.4.Math.4s...American.Indian.or.Alaska.Native 
##                                            0.59213 
##        Grade.4.Math.4s...Black.or.African.American 
##                                            0.82117 
##               Grade.4.Math.4s...Hispanic.or.Latino 
##                                            0.81676 
##        Grade.4.Math.4s...Asian.or.Pacific.Islander 
##                                            0.84493 
##                            Grade.4.Math.4s...White 
##                                            0.86212 
##                      Grade.4.Math.4s...Multiracial 
##                                            0.64858 
##       Grade.4.Math.4s...Limited.English.Proficient 
##                                            0.83663 
##  Grade.5.ELA.4s...American.Indian.or.Alaska.Native 
##                                            0.55829 
##         Grade.5.ELA.4s...Black.or.African.American 
##                                            0.82452 
##                Grade.5.ELA.4s...Hispanic.or.Latino 
##                                            0.84427 
##         Grade.5.ELA.4s...Asian.or.Pacific.Islander 
##                                            0.83678 
##                             Grade.5.ELA.4s...White 
##                                            0.85578 
##                       Grade.5.ELA.4s...Multiracial 
##                                            0.63479 
##        Grade.5.ELA.4s...Limited.English.Proficient 
##                                            0.82107 
## Grade.5.Math.4s...American.Indian.or.Alaska.Native 
##                                            0.59592 
##        Grade.5.Math.4s...Black.or.African.American 
##                                            0.83951 
##               Grade.5.Math.4s...Hispanic.or.Latino 
##                                            0.85900 
##        Grade.5.Math.4s...Asian.or.Pacific.Islander 
##                                            0.83762 
##                            Grade.5.Math.4s...White 
##                                            0.85798 
##                      Grade.5.Math.4s...Multiracial 
##                                            0.58280 
##       Grade.5.Math.4s...Limited.English.Proficient 
##                                            0.86690 
##  Grade.6.ELA.4s...American.Indian.or.Alaska.Native 
##                                            0.81010 
##         Grade.6.ELA.4s...Black.or.African.American 
##                                            0.76737 
##                Grade.6.ELA.4s...Hispanic.or.Latino 
##                                            0.86506 
##         Grade.6.ELA.4s...Asian.or.Pacific.Islander 
##                                            0.83062 
##                             Grade.6.ELA.4s...White 
##                                            0.84831 
##                       Grade.6.ELA.4s...Multiracial 
##                                            0.70268 
##        Grade.6.ELA.4s...Limited.English.Proficient 
##                                            0.80791 
## Grade.6.Math.4s...American.Indian.or.Alaska.Native 
##                                            0.81010 
##        Grade.6.Math.4s...Black.or.African.American 
##                                            0.81746 
##               Grade.6.Math.4s...Hispanic.or.Latino 
##                                            0.87116 
##        Grade.6.Math.4s...Asian.or.Pacific.Islander 
##                                            0.82670 
##                            Grade.6.Math.4s...White 
##                                            0.86703 
##                      Grade.6.Math.4s...Multiracial 
##                                            0.67418 
##       Grade.6.Math.4s...Limited.English.Proficient 
##                                            0.89397 
##  Grade.7.ELA.4s...American.Indian.or.Alaska.Native 
##                                            0.79641 
##         Grade.7.ELA.4s...Black.or.African.American 
##                                            0.80705 
##                Grade.7.ELA.4s...Hispanic.or.Latino 
##                                            0.90080 
##         Grade.7.ELA.4s...Asian.or.Pacific.Islander 
##                                            0.84543 
##                             Grade.7.ELA.4s...White 
##                                            0.87277 
##                       Grade.7.ELA.4s...Multiracial 
##                                            0.78126 
##        Grade.7.ELA.4s...Limited.English.Proficient 
##                                            0.69593 
## Grade.7.Math.4s...American.Indian.or.Alaska.Native 
##                                            0.65544 
##        Grade.7.Math.4s...Black.or.African.American 
##                                            0.82563 
##               Grade.7.Math.4s...Hispanic.or.Latino 
##                                            0.86361 
##        Grade.7.Math.4s...Asian.or.Pacific.Islander 
##                                            0.81637 
##                            Grade.7.Math.4s...White 
##                                            0.87191 
##                      Grade.7.Math.4s...Multiracial 
##                                            0.76003 
##       Grade.7.Math.4s...Limited.English.Proficient 
##                                            0.72243 
##  Grade.8.ELA.4s...American.Indian.or.Alaska.Native 
##                                            0.74277 
##         Grade.8.ELA.4s...Black.or.African.American 
##                                            0.75889 
##                Grade.8.ELA.4s...Hispanic.or.Latino 
##                                            0.93567 
##         Grade.8.ELA.4s...Asian.or.Pacific.Islander 
##                                            0.90847 
##                             Grade.8.ELA.4s...White 
##                                            0.89699 
##                       Grade.8.ELA.4s...Multiracial 
##                                            0.78324 
##        Grade.8.ELA.4s...Limited.English.Proficient 
##                                            0.36603 
## Grade.8.Math.4s...American.Indian.or.Alaska.Native 
##                                            0.59787 
##        Grade.8.Math.4s...Black.or.African.American 
##                                            0.66505 
##               Grade.8.Math.4s...Hispanic.or.Latino 
##                                            0.84764 
##        Grade.8.Math.4s...Asian.or.Pacific.Islander 
##                                            0.83705 
##                            Grade.8.Math.4s...White 
##                                            0.85969 
##                      Grade.8.Math.4s...Multiracial 
##                                            0.64781 
##       Grade.8.Math.4s...Limited.English.Proficient 
##                                            0.73390
#The overall test provided a value of .81, which is greater than .70. Thus, the data meets the sampling adequacy.
Bartlett’s Test of Sphericity:

Barlett’s test of Sphericity tests if there are enough shared variance within the data set.
(p value: .05 < below)

#Barlett Function
Bartlett.sphericity.test <- function(x)
{
  method <- "Bartlett's test of sphericity"
  data.name <- deparse(substitute(x))
  x <- subset(x, complete.cases(x)) # Omit missing values
  n <- nrow(x)
  p <- ncol(x)
  chisq <- (1-n+(2*p+5)/6)*log(det(cor(x)))
  df <- p*(p-1)/2
  p.value <- pchisq(chisq, df, lower.tail=FALSE)
  names(chisq) <- "X-squared"
  names(df) <- "df"
  return(structure(list(statistic=chisq, parameter=df, p.value=p.value,
                        method=method, data.name=data.name), class="htest"))
}

Bartlett.sphericity.test(final)
## 
##  Bartlett's test of sphericity
## 
## data:  final
## X-squared = 141000, df = 3490, p-value <0.0000000000000002
#With the p-value being less than .05, there is sufficient variance in the data to run a PCA.
Crombach’s Alpha

Cronbach’s Alpha is used to test the reliability, which means do the variables and the groupings make sense (theory and conceptually) and can be used for later analysis? (.7 and above)

psych::alpha(final, check.keys= TRUE)
## 
## Reliability analysis   
## Call: psych::alpha(x = final, check.keys = TRUE)
## 
##   raw_alpha std.alpha G6(smc) average_r S/N    ase mean sd median_r
##        0.9       0.9    0.98     0.098 9.1 0.0031  123  2    0.031
## 
##  lower alpha upper     95% confidence boundaries
## 0.9 0.9 0.91 
## 
##  Reliability if an item is dropped:
##                                                     raw_alpha std.alpha
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native-        0.9       0.9
## Grade.3.ELA.4s...Black.or.African.American-               0.9       0.9
## Grade.3.ELA.4s...Hispanic.or.Latino-                      0.9       0.9
## Grade.3.ELA.4s...Asian.or.Pacific.Islander-               0.9       0.9
## Grade.3.ELA.4s...White-                                   0.9       0.9
## Grade.3.ELA.4s...Multiracial-                             0.9       0.9
## Grade.3.ELA.4s...Limited.English.Proficient-              0.9       0.9
## Grade.3.Math.4s...American.Indian.or.Alaska.Native-       0.9       0.9
## Grade.3.Math.4s...Black.or.African.American-              0.9       0.9
## Grade.3.Math.4s...Hispanic.or.Latino-                     0.9       0.9
## Grade.3.Math.4s...Asian.or.Pacific.Islander-              0.9       0.9
## Grade.3.Math.4s...White-                                  0.9       0.9
## Grade.3.Math.4s...Multiracial-                            0.9       0.9
## Grade.3.Math.4s...Limited.English.Proficient-             0.9       0.9
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native-        0.9       0.9
## Grade.4.ELA.4s...Black.or.African.American-               0.9       0.9
## Grade.4.ELA.4s...Hispanic.or.Latino-                      0.9       0.9
## Grade.4.ELA.4s...Asian.or.Pacific.Islander-               0.9       0.9
## Grade.4.ELA.4s...White-                                   0.9       0.9
## Grade.4.ELA.4s...Multiracial-                             0.9       0.9
## Grade.4.ELA.4s...Limited.English.Proficient-              0.9       0.9
## Grade.4.Math.4s...American.Indian.or.Alaska.Native-       0.9       0.9
## Grade.4.Math.4s...Black.or.African.American-              0.9       0.9
## Grade.4.Math.4s...Hispanic.or.Latino-                     0.9       0.9
## Grade.4.Math.4s...Asian.or.Pacific.Islander-              0.9       0.9
## Grade.4.Math.4s...White-                                  0.9       0.9
## Grade.4.Math.4s...Multiracial-                            0.9       0.9
## Grade.4.Math.4s...Limited.English.Proficient-             0.9       0.9
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native-        0.9       0.9
## Grade.5.ELA.4s...Black.or.African.American-               0.9       0.9
## Grade.5.ELA.4s...Hispanic.or.Latino-                      0.9       0.9
## Grade.5.ELA.4s...Asian.or.Pacific.Islander-               0.9       0.9
## Grade.5.ELA.4s...White-                                   0.9       0.9
## Grade.5.ELA.4s...Multiracial-                             0.9       0.9
## Grade.5.ELA.4s...Limited.English.Proficient-              0.9       0.9
## Grade.5.Math.4s...American.Indian.or.Alaska.Native-       0.9       0.9
## Grade.5.Math.4s...Black.or.African.American-              0.9       0.9
## Grade.5.Math.4s...Hispanic.or.Latino-                     0.9       0.9
## Grade.5.Math.4s...Asian.or.Pacific.Islander-              0.9       0.9
## Grade.5.Math.4s...White-                                  0.9       0.9
## Grade.5.Math.4s...Multiracial-                            0.9       0.9
## Grade.5.Math.4s...Limited.English.Proficient-             0.9       0.9
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native         0.9       0.9
## Grade.6.ELA.4s...Black.or.African.American                0.9       0.9
## Grade.6.ELA.4s...Hispanic.or.Latino                       0.9       0.9
## Grade.6.ELA.4s...Asian.or.Pacific.Islander                0.9       0.9
## Grade.6.ELA.4s...White                                    0.9       0.9
## Grade.6.ELA.4s...Multiracial                              0.9       0.9
## Grade.6.ELA.4s...Limited.English.Proficient               0.9       0.9
## Grade.6.Math.4s...American.Indian.or.Alaska.Native        0.9       0.9
## Grade.6.Math.4s...Black.or.African.American               0.9       0.9
## Grade.6.Math.4s...Hispanic.or.Latino                      0.9       0.9
## Grade.6.Math.4s...Asian.or.Pacific.Islander               0.9       0.9
## Grade.6.Math.4s...White                                   0.9       0.9
## Grade.6.Math.4s...Multiracial                             0.9       0.9
## Grade.6.Math.4s...Limited.English.Proficient              0.9       0.9
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native         0.9       0.9
## Grade.7.ELA.4s...Black.or.African.American                0.9       0.9
## Grade.7.ELA.4s...Hispanic.or.Latino                       0.9       0.9
## Grade.7.ELA.4s...Asian.or.Pacific.Islander                0.9       0.9
## Grade.7.ELA.4s...White                                    0.9       0.9
## Grade.7.ELA.4s...Multiracial                              0.9       0.9
## Grade.7.ELA.4s...Limited.English.Proficient               0.9       0.9
## Grade.7.Math.4s...American.Indian.or.Alaska.Native        0.9       0.9
## Grade.7.Math.4s...Black.or.African.American               0.9       0.9
## Grade.7.Math.4s...Hispanic.or.Latino                      0.9       0.9
## Grade.7.Math.4s...Asian.or.Pacific.Islander               0.9       0.9
## Grade.7.Math.4s...White                                   0.9       0.9
## Grade.7.Math.4s...Multiracial                             0.9       0.9
## Grade.7.Math.4s...Limited.English.Proficient              0.9       0.9
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native         0.9       0.9
## Grade.8.ELA.4s...Black.or.African.American                0.9       0.9
## Grade.8.ELA.4s...Hispanic.or.Latino                       0.9       0.9
## Grade.8.ELA.4s...Asian.or.Pacific.Islander                0.9       0.9
## Grade.8.ELA.4s...White                                    0.9       0.9
## Grade.8.ELA.4s...Multiracial                              0.9       0.9
## Grade.8.ELA.4s...Limited.English.Proficient               0.9       0.9
## Grade.8.Math.4s...American.Indian.or.Alaska.Native        0.9       0.9
## Grade.8.Math.4s...Black.or.African.American               0.9       0.9
## Grade.8.Math.4s...Hispanic.or.Latino                      0.9       0.9
## Grade.8.Math.4s...Asian.or.Pacific.Islander               0.9       0.9
## Grade.8.Math.4s...White                                   0.9       0.9
## Grade.8.Math.4s...Multiracial                             0.9       0.9
## Grade.8.Math.4s...Limited.English.Proficient              0.9       0.9
##                                                     G6(smc) average_r S/N
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native-     0.98     0.099 9.2
## Grade.3.ELA.4s...Black.or.African.American-            0.98     0.099 9.1
## Grade.3.ELA.4s...Hispanic.or.Latino-                   0.98     0.097 9.0
## Grade.3.ELA.4s...Asian.or.Pacific.Islander-            0.98     0.097 8.9
## Grade.3.ELA.4s...White-                                0.98     0.097 8.9
## Grade.3.ELA.4s...Multiracial-                          0.98     0.098 9.1
## Grade.3.ELA.4s...Limited.English.Proficient-           0.98     0.099 9.1
## Grade.3.Math.4s...American.Indian.or.Alaska.Native-    0.98     0.099 9.2
## Grade.3.Math.4s...Black.or.African.American-           0.98     0.099 9.1
## Grade.3.Math.4s...Hispanic.or.Latino-                  0.98     0.097 8.9
## Grade.3.Math.4s...Asian.or.Pacific.Islander-           0.98     0.097 8.9
## Grade.3.Math.4s...White-                               0.98     0.097 8.9
## Grade.3.Math.4s...Multiracial-                         0.98     0.098 9.1
## Grade.3.Math.4s...Limited.English.Proficient-          0.98     0.098 9.0
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native-     0.98     0.099 9.1
## Grade.4.ELA.4s...Black.or.African.American-            0.98     0.099 9.1
## Grade.4.ELA.4s...Hispanic.or.Latino-                   0.98     0.097 8.9
## Grade.4.ELA.4s...Asian.or.Pacific.Islander-            0.98     0.097 8.9
## Grade.4.ELA.4s...White-                                0.98     0.097 8.9
## Grade.4.ELA.4s...Multiracial-                          0.98     0.098 9.1
## Grade.4.ELA.4s...Limited.English.Proficient-           0.98     0.099 9.1
## Grade.4.Math.4s...American.Indian.or.Alaska.Native-    0.98     0.099 9.1
## Grade.4.Math.4s...Black.or.African.American-           0.98     0.099 9.1
## Grade.4.Math.4s...Hispanic.or.Latino-                  0.98     0.097 8.9
## Grade.4.Math.4s...Asian.or.Pacific.Islander-           0.98     0.097 8.9
## Grade.4.Math.4s...White-                               0.98     0.097 8.9
## Grade.4.Math.4s...Multiracial-                         0.98     0.098 9.1
## Grade.4.Math.4s...Limited.English.Proficient-          0.98     0.098 9.0
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native-     0.98     0.099 9.1
## Grade.5.ELA.4s...Black.or.African.American-            0.98     0.099 9.1
## Grade.5.ELA.4s...Hispanic.or.Latino-                   0.98     0.097 8.9
## Grade.5.ELA.4s...Asian.or.Pacific.Islander-            0.98     0.097 8.9
## Grade.5.ELA.4s...White-                                0.98     0.097 8.9
## Grade.5.ELA.4s...Multiracial-                          0.98     0.099 9.1
## Grade.5.ELA.4s...Limited.English.Proficient-           0.98     0.099 9.1
## Grade.5.Math.4s...American.Indian.or.Alaska.Native-    0.98     0.099 9.1
## Grade.5.Math.4s...Black.or.African.American-           0.98     0.099 9.1
## Grade.5.Math.4s...Hispanic.or.Latino-                  0.98     0.097 9.0
## Grade.5.Math.4s...Asian.or.Pacific.Islander-           0.98     0.097 8.9
## Grade.5.Math.4s...White-                               0.98     0.097 8.9
## Grade.5.Math.4s...Multiracial-                         0.98     0.099 9.1
## Grade.5.Math.4s...Limited.English.Proficient-          0.98     0.098 9.0
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native      0.98     0.098 9.0
## Grade.6.ELA.4s...Black.or.African.American             0.98     0.098 9.0
## Grade.6.ELA.4s...Hispanic.or.Latino                    0.98     0.096 8.8
## Grade.6.ELA.4s...Asian.or.Pacific.Islander             0.98     0.095 8.7
## Grade.6.ELA.4s...White                                 0.98     0.096 8.8
## Grade.6.ELA.4s...Multiracial                           0.98     0.097 8.9
## Grade.6.ELA.4s...Limited.English.Proficient            0.98     0.099 9.1
## Grade.6.Math.4s...American.Indian.or.Alaska.Native     0.98     0.098 9.0
## Grade.6.Math.4s...Black.or.African.American            0.98     0.099 9.1
## Grade.6.Math.4s...Hispanic.or.Latino                   0.98     0.096 8.8
## Grade.6.Math.4s...Asian.or.Pacific.Islander            0.98     0.095 8.7
## Grade.6.Math.4s...White                                0.98     0.096 8.8
## Grade.6.Math.4s...Multiracial                          0.98     0.097 8.9
## Grade.6.Math.4s...Limited.English.Proficient           0.98     0.097 8.9
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native      0.98     0.098 9.1
## Grade.7.ELA.4s...Black.or.African.American             0.98     0.098 9.0
## Grade.7.ELA.4s...Hispanic.or.Latino                    0.98     0.096 8.8
## Grade.7.ELA.4s...Asian.or.Pacific.Islander             0.98     0.095 8.7
## Grade.7.ELA.4s...White                                 0.98     0.096 8.8
## Grade.7.ELA.4s...Multiracial                           0.98     0.098 9.0
## Grade.7.ELA.4s...Limited.English.Proficient            0.98     0.099 9.1
## Grade.7.Math.4s...American.Indian.or.Alaska.Native     0.98     0.098 9.0
## Grade.7.Math.4s...Black.or.African.American            0.98     0.098 9.1
## Grade.7.Math.4s...Hispanic.or.Latino                   0.98     0.096 8.9
## Grade.7.Math.4s...Asian.or.Pacific.Islander            0.98     0.095 8.7
## Grade.7.Math.4s...White                                0.98     0.096 8.8
## Grade.7.Math.4s...Multiracial                          0.98     0.098 9.0
## Grade.7.Math.4s...Limited.English.Proficient           0.98     0.097 9.0
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native      0.98     0.098 9.0
## Grade.8.ELA.4s...Black.or.African.American             0.98     0.098 9.0
## Grade.8.ELA.4s...Hispanic.or.Latino                    0.98     0.096 8.8
## Grade.8.ELA.4s...Asian.or.Pacific.Islander             0.98     0.095 8.7
## Grade.8.ELA.4s...White                                 0.98     0.096 8.8
## Grade.8.ELA.4s...Multiracial                           0.98     0.098 9.0
## Grade.8.ELA.4s...Limited.English.Proficient            0.98     0.099 9.2
## Grade.8.Math.4s...American.Indian.or.Alaska.Native     0.98     0.098 9.1
## Grade.8.Math.4s...Black.or.African.American            0.98     0.099 9.1
## Grade.8.Math.4s...Hispanic.or.Latino                   0.98     0.097 9.0
## Grade.8.Math.4s...Asian.or.Pacific.Islander            0.98     0.096 8.8
## Grade.8.Math.4s...White                                0.98     0.096 8.8
## Grade.8.Math.4s...Multiracial                          0.98     0.098 9.0
## Grade.8.Math.4s...Limited.English.Proficient           0.98     0.097 9.0
##                                                     alpha se var.r med.r
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native-    0.0031 0.037 0.032
## Grade.3.ELA.4s...Black.or.African.American-           0.0031 0.036 0.031
## Grade.3.ELA.4s...Hispanic.or.Latino-                  0.0031 0.037 0.030
## Grade.3.ELA.4s...Asian.or.Pacific.Islander-           0.0031 0.036 0.030
## Grade.3.ELA.4s...White-                               0.0031 0.036 0.030
## Grade.3.ELA.4s...Multiracial-                         0.0031 0.037 0.031
## Grade.3.ELA.4s...Limited.English.Proficient-          0.0031 0.037 0.031
## Grade.3.Math.4s...American.Indian.or.Alaska.Native-   0.0031 0.037 0.031
## Grade.3.Math.4s...Black.or.African.American-          0.0031 0.036 0.031
## Grade.3.Math.4s...Hispanic.or.Latino-                 0.0031 0.037 0.030
## Grade.3.Math.4s...Asian.or.Pacific.Islander-          0.0031 0.036 0.030
## Grade.3.Math.4s...White-                              0.0031 0.036 0.030
## Grade.3.Math.4s...Multiracial-                        0.0031 0.037 0.031
## Grade.3.Math.4s...Limited.English.Proficient-         0.0031 0.037 0.031
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native-    0.0031 0.037 0.031
## Grade.4.ELA.4s...Black.or.African.American-           0.0031 0.036 0.031
## Grade.4.ELA.4s...Hispanic.or.Latino-                  0.0031 0.037 0.029
## Grade.4.ELA.4s...Asian.or.Pacific.Islander-           0.0031 0.036 0.030
## Grade.4.ELA.4s...White-                               0.0031 0.036 0.030
## Grade.4.ELA.4s...Multiracial-                         0.0031 0.037 0.031
## Grade.4.ELA.4s...Limited.English.Proficient-          0.0031 0.037 0.031
## Grade.4.Math.4s...American.Indian.or.Alaska.Native-   0.0031 0.037 0.031
## Grade.4.Math.4s...Black.or.African.American-          0.0031 0.036 0.031
## Grade.4.Math.4s...Hispanic.or.Latino-                 0.0031 0.037 0.030
## Grade.4.Math.4s...Asian.or.Pacific.Islander-          0.0031 0.036 0.030
## Grade.4.Math.4s...White-                              0.0031 0.036 0.030
## Grade.4.Math.4s...Multiracial-                        0.0031 0.037 0.031
## Grade.4.Math.4s...Limited.English.Proficient-         0.0031 0.037 0.031
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native-    0.0031 0.037 0.032
## Grade.5.ELA.4s...Black.or.African.American-           0.0031 0.036 0.031
## Grade.5.ELA.4s...Hispanic.or.Latino-                  0.0031 0.037 0.030
## Grade.5.ELA.4s...Asian.or.Pacific.Islander-           0.0031 0.036 0.030
## Grade.5.ELA.4s...White-                               0.0031 0.036 0.031
## Grade.5.ELA.4s...Multiracial-                         0.0031 0.037 0.031
## Grade.5.ELA.4s...Limited.English.Proficient-          0.0031 0.037 0.031
## Grade.5.Math.4s...American.Indian.or.Alaska.Native-   0.0031 0.037 0.031
## Grade.5.Math.4s...Black.or.African.American-          0.0031 0.036 0.031
## Grade.5.Math.4s...Hispanic.or.Latino-                 0.0031 0.037 0.030
## Grade.5.Math.4s...Asian.or.Pacific.Islander-          0.0031 0.036 0.030
## Grade.5.Math.4s...White-                              0.0031 0.036 0.031
## Grade.5.Math.4s...Multiracial-                        0.0031 0.037 0.031
## Grade.5.Math.4s...Limited.English.Proficient-         0.0031 0.036 0.031
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native     0.0031 0.037 0.031
## Grade.6.ELA.4s...Black.or.African.American            0.0031 0.036 0.030
## Grade.6.ELA.4s...Hispanic.or.Latino                   0.0032 0.036 0.030
## Grade.6.ELA.4s...Asian.or.Pacific.Islander            0.0034 0.036 0.030
## Grade.6.ELA.4s...White                                0.0033 0.036 0.030
## Grade.6.ELA.4s...Multiracial                          0.0031 0.036 0.031
## Grade.6.ELA.4s...Limited.English.Proficient           0.0031 0.037 0.031
## Grade.6.Math.4s...American.Indian.or.Alaska.Native    0.0031 0.037 0.031
## Grade.6.Math.4s...Black.or.African.American           0.0031 0.036 0.030
## Grade.6.Math.4s...Hispanic.or.Latino                  0.0032 0.036 0.030
## Grade.6.Math.4s...Asian.or.Pacific.Islander           0.0034 0.036 0.030
## Grade.6.Math.4s...White                               0.0033 0.036 0.030
## Grade.6.Math.4s...Multiracial                         0.0031 0.036 0.031
## Grade.6.Math.4s...Limited.English.Proficient          0.0032 0.036 0.030
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native     0.0031 0.037 0.031
## Grade.7.ELA.4s...Black.or.African.American            0.0031 0.037 0.030
## Grade.7.ELA.4s...Hispanic.or.Latino                   0.0032 0.036 0.029
## Grade.7.ELA.4s...Asian.or.Pacific.Islander            0.0034 0.036 0.030
## Grade.7.ELA.4s...White                                0.0033 0.036 0.030
## Grade.7.ELA.4s...Multiracial                          0.0031 0.036 0.031
## Grade.7.ELA.4s...Limited.English.Proficient           0.0031 0.037 0.031
## Grade.7.Math.4s...American.Indian.or.Alaska.Native    0.0031 0.037 0.031
## Grade.7.Math.4s...Black.or.African.American           0.0031 0.036 0.030
## Grade.7.Math.4s...Hispanic.or.Latino                  0.0032 0.036 0.030
## Grade.7.Math.4s...Asian.or.Pacific.Islander           0.0034 0.036 0.029
## Grade.7.Math.4s...White                               0.0034 0.036 0.030
## Grade.7.Math.4s...Multiracial                         0.0031 0.037 0.031
## Grade.7.Math.4s...Limited.English.Proficient          0.0031 0.037 0.030
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native     0.0031 0.037 0.031
## Grade.8.ELA.4s...Black.or.African.American            0.0031 0.037 0.030
## Grade.8.ELA.4s...Hispanic.or.Latino                   0.0032 0.036 0.029
## Grade.8.ELA.4s...Asian.or.Pacific.Islander            0.0034 0.036 0.030
## Grade.8.ELA.4s...White                                0.0033 0.036 0.030
## Grade.8.ELA.4s...Multiracial                          0.0031 0.037 0.031
## Grade.8.ELA.4s...Limited.English.Proficient           0.0031 0.037 0.031
## Grade.8.Math.4s...American.Indian.or.Alaska.Native    0.0031 0.037 0.031
## Grade.8.Math.4s...Black.or.African.American           0.0031 0.037 0.031
## Grade.8.Math.4s...Hispanic.or.Latino                  0.0032 0.037 0.030
## Grade.8.Math.4s...Asian.or.Pacific.Islander           0.0034 0.036 0.030
## Grade.8.Math.4s...White                               0.0033 0.036 0.030
## Grade.8.Math.4s...Multiracial                         0.0031 0.037 0.031
## Grade.8.Math.4s...Limited.English.Proficient          0.0031 0.037 0.030
## 
##  Item statistics 
##                                                        n raw.r std.r r.cor
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native-  1272 0.022 0.096 0.080
## Grade.3.ELA.4s...Black.or.African.American-         1272 0.125 0.179 0.174
## Grade.3.ELA.4s...Hispanic.or.Latino-                1272 0.252 0.335 0.326
## Grade.3.ELA.4s...Asian.or.Pacific.Islander-         1272 0.381 0.410 0.411
## Grade.3.ELA.4s...White-                             1272 0.318 0.366 0.366
## Grade.3.ELA.4s...Multiracial-                       1272 0.130 0.229 0.221
## Grade.3.ELA.4s...Limited.English.Proficient-        1272 0.103 0.146 0.120
## Grade.3.Math.4s...American.Indian.or.Alaska.Native- 1272 0.026 0.102 0.083
## Grade.3.Math.4s...Black.or.African.American-        1272 0.113 0.149 0.146
## Grade.3.Math.4s...Hispanic.or.Latino-               1272 0.271 0.355 0.350
## Grade.3.Math.4s...Asian.or.Pacific.Islander-        1272 0.404 0.430 0.432
## Grade.3.Math.4s...White-                            1272 0.338 0.387 0.388
## Grade.3.Math.4s...Multiracial-                      1272 0.134 0.228 0.220
## Grade.3.Math.4s...Limited.English.Proficient-       1272 0.265 0.313 0.309
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native-  1272 0.056 0.184 0.185
## Grade.4.ELA.4s...Black.or.African.American-         1272 0.137 0.189 0.186
## Grade.4.ELA.4s...Hispanic.or.Latino-                1272 0.300 0.395 0.394
## Grade.4.ELA.4s...Asian.or.Pacific.Islander-         1272 0.410 0.438 0.441
## Grade.4.ELA.4s...White-                             1272 0.340 0.394 0.396
## Grade.4.ELA.4s...Multiracial-                       1272 0.122 0.220 0.219
## Grade.4.ELA.4s...Limited.English.Proficient-        1272 0.140 0.196 0.173
## Grade.4.Math.4s...American.Indian.or.Alaska.Native- 1272 0.052 0.179 0.179
## Grade.4.Math.4s...Black.or.African.American-        1272 0.119 0.156 0.154
## Grade.4.Math.4s...Hispanic.or.Latino-               1272 0.274 0.363 0.362
## Grade.4.Math.4s...Asian.or.Pacific.Islander-        1272 0.407 0.434 0.437
## Grade.4.Math.4s...White-                            1272 0.339 0.390 0.392
## Grade.4.Math.4s...Multiracial-                      1272 0.122 0.215 0.214
## Grade.4.Math.4s...Limited.English.Proficient-       1272 0.270 0.314 0.309
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native-  1272 0.041 0.154 0.153
## Grade.5.ELA.4s...Black.or.African.American-         1272 0.117 0.166 0.159
## Grade.5.ELA.4s...Hispanic.or.Latino-                1272 0.289 0.375 0.369
## Grade.5.ELA.4s...Asian.or.Pacific.Islander-         1272 0.392 0.408 0.410
## Grade.5.ELA.4s...White-                             1272 0.306 0.367 0.369
## Grade.5.ELA.4s...Multiracial-                       1272 0.093 0.167 0.155
## Grade.5.ELA.4s...Limited.English.Proficient-        1272 0.088 0.144 0.115
## Grade.5.Math.4s...American.Indian.or.Alaska.Native- 1272 0.046 0.166 0.166
## Grade.5.Math.4s...Black.or.African.American-        1272 0.090 0.132 0.126
## Grade.5.Math.4s...Hispanic.or.Latino-               1272 0.265 0.347 0.342
## Grade.5.Math.4s...Asian.or.Pacific.Islander-        1272 0.385 0.400 0.402
## Grade.5.Math.4s...White-                            1272 0.319 0.376 0.378
## Grade.5.Math.4s...Multiracial-                      1272 0.095 0.173 0.161
## Grade.5.Math.4s...Limited.English.Proficient-       1272 0.257 0.288 0.282
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native   1272 0.123 0.263 0.260
## Grade.6.ELA.4s...Black.or.African.American          1272 0.211 0.263 0.260
## Grade.6.ELA.4s...Hispanic.or.Latino                 1272 0.543 0.519 0.520
## Grade.6.ELA.4s...Asian.or.Pacific.Islander          1272 0.760 0.616 0.622
## Grade.6.ELA.4s...White                              1272 0.687 0.542 0.547
## Grade.6.ELA.4s...Multiracial                        1272 0.340 0.376 0.377
## Grade.6.ELA.4s...Limited.English.Proficient         1272 0.170 0.191 0.165
## Grade.6.Math.4s...American.Indian.or.Alaska.Native  1272 0.108 0.249 0.246
## Grade.6.Math.4s...Black.or.African.American         1272 0.152 0.184 0.182
## Grade.6.Math.4s...Hispanic.or.Latino                1272 0.502 0.477 0.478
## Grade.6.Math.4s...Asian.or.Pacific.Islander         1272 0.759 0.625 0.631
## Grade.6.Math.4s...White                             1272 0.679 0.539 0.544
## Grade.6.Math.4s...Multiracial                       1272 0.336 0.358 0.359
## Grade.6.Math.4s...Limited.English.Proficient        1272 0.477 0.442 0.442
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native   1272 0.090 0.216 0.207
## Grade.7.ELA.4s...Black.or.African.American          1272 0.266 0.326 0.322
## Grade.7.ELA.4s...Hispanic.or.Latino                 1272 0.554 0.537 0.538
## Grade.7.ELA.4s...Asian.or.Pacific.Islander          1272 0.759 0.605 0.611
## Grade.7.ELA.4s...White                              1272 0.686 0.545 0.549
## Grade.7.ELA.4s...Multiracial                        1272 0.262 0.323 0.324
## Grade.7.ELA.4s...Limited.English.Proficient         1272 0.263 0.204 0.184
## Grade.7.Math.4s...American.Indian.or.Alaska.Native  1272 0.127 0.241 0.235
## Grade.7.Math.4s...Black.or.African.American         1272 0.192 0.212 0.207
## Grade.7.Math.4s...Hispanic.or.Latino                1272 0.489 0.472 0.472
## Grade.7.Math.4s...Asian.or.Pacific.Islander         1272 0.765 0.626 0.632
## Grade.7.Math.4s...White                             1272 0.704 0.563 0.568
## Grade.7.Math.4s...Multiracial                       1272 0.273 0.326 0.327
## Grade.7.Math.4s...Limited.English.Proficient        1272 0.362 0.350 0.350
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native   1272 0.123 0.255 0.253
## Grade.8.ELA.4s...Black.or.African.American          1272 0.231 0.301 0.298
## Grade.8.ELA.4s...Hispanic.or.Latino                 1272 0.510 0.502 0.500
## Grade.8.ELA.4s...Asian.or.Pacific.Islander          1272 0.755 0.606 0.611
## Grade.8.ELA.4s...White                              1272 0.699 0.568 0.572
## Grade.8.ELA.4s...Multiracial                        1272 0.215 0.263 0.256
## Grade.8.ELA.4s...Limited.English.Proficient         1272 0.104 0.109 0.085
## Grade.8.Math.4s...American.Indian.or.Alaska.Native  1272 0.199 0.227 0.216
## Grade.8.Math.4s...Black.or.African.American         1272 0.113 0.136 0.129
## Grade.8.Math.4s...Hispanic.or.Latino                1272 0.353 0.342 0.334
## Grade.8.Math.4s...Asian.or.Pacific.Islander         1272 0.685 0.549 0.552
## Grade.8.Math.4s...White                             1272 0.635 0.513 0.513
## Grade.8.Math.4s...Multiracial                       1272 0.228 0.274 0.272
## Grade.8.Math.4s...Limited.English.Proficient        1272 0.355 0.353 0.353
##                                                     r.drop     mean     sd
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native-   0.021 245.9906  0.148
## Grade.3.ELA.4s...Black.or.African.American-          0.111 245.2862  2.273
## Grade.3.ELA.4s...Hispanic.or.Latino-                 0.241 245.1714  1.839
## Grade.3.ELA.4s...Asian.or.Pacific.Islander-          0.359 244.6525  4.114
## Grade.3.ELA.4s...White-                              0.296 244.6297  4.096
## Grade.3.ELA.4s...Multiracial-                        0.128 245.9607  0.353
## Grade.3.ELA.4s...Limited.English.Proficient-         0.102 245.9756  0.182
## Grade.3.Math.4s...American.Indian.or.Alaska.Native-  0.024 245.9725  0.266
## Grade.3.Math.4s...Black.or.African.American-         0.071 243.7445  7.041
## Grade.3.Math.4s...Hispanic.or.Latino-                0.241 243.1847  5.408
## Grade.3.Math.4s...Asian.or.Pacific.Islander-         0.343 241.9741 11.844
## Grade.3.Math.4s...White-                             0.293 242.9898  8.294
## Grade.3.Math.4s...Multiracial-                       0.130 245.9340  0.557
## Grade.3.Math.4s...Limited.English.Proficient-        0.253 245.4693  2.182
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native-   0.054 245.9764  0.304
## Grade.4.ELA.4s...Black.or.African.American-          0.114 244.6509  3.917
## Grade.4.ELA.4s...Hispanic.or.Latino-                 0.278 243.9701  4.108
## Grade.4.ELA.4s...Asian.or.Pacific.Islander-          0.372 243.4748  7.497
## Grade.4.ELA.4s...White-                              0.301 243.4599  7.276
## Grade.4.ELA.4s...Multiracial-                        0.119 245.9489  0.522
## Grade.4.ELA.4s...Limited.English.Proficient-         0.138 245.9528  0.306
## Grade.4.Math.4s...American.Indian.or.Alaska.Native-  0.049 245.9631  0.464
## Grade.4.Math.4s...Black.or.African.American-         0.084 244.2390  5.884
## Grade.4.Math.4s...Hispanic.or.Latino-                0.243 243.2822  5.565
## Grade.4.Math.4s...Asian.or.Pacific.Islander-         0.345 242.0503 11.974
## Grade.4.Math.4s...White-                             0.294 243.0881  8.295
## Grade.4.Math.4s...Multiracial-                       0.118 245.9371  0.624
## Grade.4.Math.4s...Limited.English.Proficient-        0.260 245.6132  1.685
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native-   0.040 245.9827  0.304
## Grade.5.ELA.4s...Black.or.African.American-          0.104 245.2500  2.068
## Grade.5.ELA.4s...Hispanic.or.Latino-                 0.276 244.7925  2.357
## Grade.5.ELA.4s...Asian.or.Pacific.Islander-          0.364 244.1981  5.330
## Grade.5.ELA.4s...White-                              0.276 244.1211  5.594
## Grade.5.ELA.4s...Multiracial-                        0.091 245.9733  0.347
## Grade.5.ELA.4s...Limited.English.Proficient-         0.087 245.9898  0.122
## Grade.5.Math.4s...American.Indian.or.Alaska.Native-  0.044 245.9717  0.462
## Grade.5.Math.4s...Black.or.African.American-         0.072 245.1195  3.120
## Grade.5.Math.4s...Hispanic.or.Latino-                0.246 244.3373  3.484
## Grade.5.Math.4s...Asian.or.Pacific.Islander-         0.330 242.7508 10.454
## Grade.5.Math.4s...White-                             0.282 243.6478  6.802
## Grade.5.Math.4s...Multiracial-                       0.093 245.9709  0.370
## Grade.5.Math.4s...Limited.English.Proficient-        0.252 245.8247  0.919
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native    0.121   0.0228  0.295
## Grade.6.ELA.4s...Black.or.African.American           0.191   1.1211  3.548
## Grade.6.ELA.4s...Hispanic.or.Latino                  0.526   1.5362  3.912
## Grade.6.ELA.4s...Asian.or.Pacific.Islander           0.726   2.6903 12.579
## Grade.6.ELA.4s...White                               0.652   2.1714 10.518
## Grade.6.ELA.4s...Multiracial                         0.336   0.0731  0.834
## Grade.6.ELA.4s...Limited.English.Proficient          0.170   0.0189  0.142
## Grade.6.Math.4s...American.Indian.or.Alaska.Native   0.107   0.0236  0.314
## Grade.6.Math.4s...Black.or.African.American          0.122   1.4591  5.117
## Grade.6.Math.4s...Hispanic.or.Latino                 0.474   2.2854  5.991
## Grade.6.Math.4s...Asian.or.Pacific.Islander          0.704   4.2893 19.097
## Grade.6.Math.4s...White                              0.629   2.9906 14.421
## Grade.6.Math.4s...Multiracial                        0.331   0.0755  1.054
## Grade.6.Math.4s...Limited.English.Proficient         0.470   0.2791  1.499
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native    0.088   0.0189  0.274
## Grade.7.ELA.4s...Black.or.African.American           0.252   0.6808  2.381
## Grade.7.ELA.4s...Hispanic.or.Latino                  0.539   1.2123  3.424
## Grade.7.ELA.4s...Asian.or.Pacific.Islander           0.734   1.9992  9.448
## Grade.7.ELA.4s...White                               0.652   1.9843 10.051
## Grade.7.ELA.4s...Multiracial                         0.260   0.0259  0.427
## Grade.7.ELA.4s...Limited.English.Proficient          0.263   0.0024  0.049
## Grade.7.Math.4s...American.Indian.or.Alaska.Native   0.126   0.0189  0.294
## Grade.7.Math.4s...Black.or.African.American          0.174   0.7476  3.088
## Grade.7.Math.4s...Hispanic.or.Latino                 0.469   1.3601  4.380
## Grade.7.Math.4s...Asian.or.Pacific.Islander          0.722   3.3664 15.694
## Grade.7.Math.4s...White                              0.665   2.3168 12.119
## Grade.7.Math.4s...Multiracial                        0.270   0.0338  0.495
## Grade.7.Math.4s...Limited.English.Proficient         0.356   0.1242  1.010
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native    0.122   0.0134  0.219
## Grade.8.ELA.4s...Black.or.African.American           0.212   0.9167  3.309
## Grade.8.ELA.4s...Hispanic.or.Latino                  0.491   1.5204  4.241
## Grade.8.ELA.4s...Asian.or.Pacific.Islander           0.724   2.2555 11.117
## Grade.8.ELA.4s...White                               0.669   1.9316  9.206
## Grade.8.ELA.4s...Multiracial                         0.213   0.0157  0.324
## Grade.8.ELA.4s...Limited.English.Proficient          0.104   0.0016  0.040
## Grade.8.Math.4s...American.Indian.or.Alaska.Native   0.199   0.0031  0.069
## Grade.8.Math.4s...Black.or.African.American          0.089   0.6101  3.966
## Grade.8.Math.4s...Hispanic.or.Latino                 0.332   0.9473  4.056
## Grade.8.Math.4s...Asian.or.Pacific.Islander          0.641   1.9843 12.841
## Grade.8.Math.4s...White                              0.609   0.9709  6.880
## Grade.8.Math.4s...Multiracial                        0.228   0.0024  0.084
## Grade.8.Math.4s...Limited.English.Proficient         0.348   0.1596  1.321
#With the reliability value at .9, it shows that the groupings of the variables makes sense and is sufficient enough for PCA

Keep in mind that PCA, FA, CCA, Correspondence Analysis, and LDA are version of linear combinations, all will require assumptions for regression analysis.

Ready to perform PCA

#PCA
PCA_2a <- prcomp(final, center=T, scale=T)
plot(PCA_2a)
abline(1,0)

#it seems that the first 10 components have an eigen value greater than 1. Let's now look at the cumulative proportion of variance that each component has.

summary(PCA_2a)
## Importance of components:
##                          PC1   PC2    PC3    PC4    PC5    PC6   PC7
## Standard deviation     3.477 2.884 2.5552 2.3874 2.2232 2.0276 1.923
## Proportion of Variance 0.144 0.099 0.0777 0.0678 0.0588 0.0489 0.044
## Cumulative Proportion  0.144 0.243 0.3207 0.3885 0.4474 0.4963 0.540
##                           PC8    PC9   PC10   PC11   PC12   PC13   PC14
## Standard deviation     1.8651 1.8474 1.5358 1.4970 1.3247 1.2447 1.2370
## Proportion of Variance 0.0414 0.0406 0.0281 0.0267 0.0209 0.0184 0.0182
## Cumulative Proportion  0.5817 0.6223 0.6504 0.6771 0.6980 0.7164 0.7347
##                          PC15   PC16  PC17   PC18   PC19  PC20   PC21
## Standard deviation     1.2228 1.1704 1.086 1.0341 1.0151 1.004 0.9553
## Proportion of Variance 0.0178 0.0163 0.014 0.0127 0.0123 0.012 0.0109
## Cumulative Proportion  0.7525 0.7688 0.783 0.7955 0.8078 0.820 0.8306
##                          PC22   PC23    PC24    PC25    PC26    PC27
## Standard deviation     0.9478 0.9306 0.89877 0.88352 0.85317 0.82059
## Proportion of Variance 0.0107 0.0103 0.00962 0.00929 0.00867 0.00802
## Cumulative Proportion  0.8414 0.8517 0.86128 0.87057 0.87923 0.88725
##                           PC28    PC29    PC30    PC31    PC32    PC33
## Standard deviation     0.78666 0.76242 0.69888 0.69079 0.68860 0.64573
## Proportion of Variance 0.00737 0.00692 0.00581 0.00568 0.00564 0.00496
## Cumulative Proportion  0.89462 0.90154 0.90735 0.91303 0.91868 0.92364
##                           PC34    PC35   PC36    PC37    PC38    PC39
## Standard deviation     0.63541 0.61732 0.5726 0.55803 0.53519 0.51245
## Proportion of Variance 0.00481 0.00454 0.0039 0.00371 0.00341 0.00313
## Cumulative Proportion  0.92845 0.93298 0.9369 0.94060 0.94401 0.94713
##                           PC40    PC41    PC42    PC43    PC44    PC45
## Standard deviation     0.50840 0.50150 0.48973 0.48567 0.46618 0.45063
## Proportion of Variance 0.00308 0.00299 0.00286 0.00281 0.00259 0.00242
## Cumulative Proportion  0.95021 0.95320 0.95606 0.95887 0.96145 0.96387
##                           PC46    PC47    PC48    PC49    PC50    PC51
## Standard deviation     0.43397 0.42068 0.41555 0.41205 0.40419 0.39242
## Proportion of Variance 0.00224 0.00211 0.00206 0.00202 0.00194 0.00183
## Cumulative Proportion  0.96611 0.96822 0.97027 0.97230 0.97424 0.97607
##                          PC52    PC53    PC54    PC55    PC56    PC57
## Standard deviation     0.3782 0.36745 0.36411 0.33833 0.33186 0.32808
## Proportion of Variance 0.0017 0.00161 0.00158 0.00136 0.00131 0.00128
## Cumulative Proportion  0.9778 0.97938 0.98096 0.98233 0.98364 0.98492
##                           PC58    PC59    PC60    PC61    PC62    PC63
## Standard deviation     0.31357 0.30875 0.29473 0.28561 0.28326 0.26685
## Proportion of Variance 0.00117 0.00113 0.00103 0.00097 0.00096 0.00085
## Cumulative Proportion  0.98609 0.98722 0.98826 0.98923 0.99018 0.99103
##                           PC64    PC65    PC66    PC67    PC68    PC69
## Standard deviation     0.25710 0.25525 0.25223 0.23948 0.23404 0.22728
## Proportion of Variance 0.00079 0.00078 0.00076 0.00068 0.00065 0.00061
## Cumulative Proportion  0.99182 0.99259 0.99335 0.99403 0.99469 0.99530
##                           PC70    PC71    PC72    PC73   PC74   PC75
## Standard deviation     0.21453 0.21295 0.20134 0.19830 0.1844 0.1830
## Proportion of Variance 0.00055 0.00054 0.00048 0.00047 0.0004 0.0004
## Cumulative Proportion  0.99585 0.99639 0.99687 0.99734 0.9977 0.9981
##                           PC76    PC77    PC78    PC79    PC80    PC81
## Standard deviation     0.17257 0.16008 0.15543 0.14058 0.12335 0.11530
## Proportion of Variance 0.00035 0.00031 0.00029 0.00024 0.00018 0.00016
## Cumulative Proportion  0.99850 0.99880 0.99909 0.99933 0.99951 0.99967
##                           PC82    PC83    PC84
## Standard deviation     0.10847 0.10606 0.07150
## Proportion of Variance 0.00014 0.00013 0.00006
## Cumulative Proportion  0.99981 0.99994 1.00000
# with 9 components, 62.2% of the variance is explained. Lastly, lets look at the knee of the plot.


pCA_2A1 <- PCA(final, graph = FALSE)
fviz_eig(pCA_2A1, addlabels = TRUE, ylim = c(0, 35), ncp=30)

#It looks like after 6 components, the plot levels off.

#From the 3 tests, let's run a PCA using 6 principal components


pca_2b <- psych::principal(final, rotate="varimax", nfactors=6)
pca_2b
## Principal Components Analysis
## Call: psych::principal(r = final, nfactors = 6, rotate = "varimax")
## Standardized loadings (pattern matrix) based upon correlation matrix
##                                                      RC1   RC5   RC2   RC4
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native  -0.03  0.00  0.04 -0.04
## Grade.3.ELA.4s...Black.or.African.American         -0.08 -0.04 -0.02  0.02
## Grade.3.ELA.4s...Hispanic.or.Latino                 0.04 -0.12  0.26  0.21
## Grade.3.ELA.4s...Asian.or.Pacific.Islander         -0.05  0.02  0.78  0.21
## Grade.3.ELA.4s...White                             -0.05 -0.01  0.06  0.86
## Grade.3.ELA.4s...Multiracial                       -0.01  0.00 -0.03  0.55
## Grade.3.ELA.4s...Limited.English.Proficient         0.03 -0.03  0.29 -0.03
## Grade.3.Math.4s...American.Indian.or.Alaska.Native -0.03 -0.01  0.07 -0.05
## Grade.3.Math.4s...Black.or.African.American        -0.07 -0.05 -0.04  0.00
## Grade.3.Math.4s...Hispanic.or.Latino                0.04 -0.15  0.29  0.14
## Grade.3.Math.4s...Asian.or.Pacific.Islander        -0.06  0.02  0.90  0.12
## Grade.3.Math.4s...White                            -0.06 -0.01  0.06  0.89
## Grade.3.Math.4s...Multiracial                      -0.02 -0.01 -0.05  0.55
## Grade.3.Math.4s...Limited.English.Proficient       -0.03 -0.01  0.72 -0.07
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native  -0.04  0.01  0.16 -0.07
## Grade.4.ELA.4s...Black.or.African.American         -0.09 -0.05 -0.03  0.02
## Grade.4.ELA.4s...Hispanic.or.Latino                 0.05 -0.13  0.37  0.21
## Grade.4.ELA.4s...Asian.or.Pacific.Islander         -0.05  0.02  0.86  0.19
## Grade.4.ELA.4s...White                             -0.06 -0.01  0.06  0.92
## Grade.4.ELA.4s...Multiracial                       -0.02  0.03  0.01  0.52
## Grade.4.ELA.4s...Limited.English.Proficient         0.01 -0.03  0.36 -0.03
## Grade.4.Math.4s...American.Indian.or.Alaska.Native -0.03  0.01  0.16 -0.07
## Grade.4.Math.4s...Black.or.African.American        -0.07 -0.05 -0.02  0.01
## Grade.4.Math.4s...Hispanic.or.Latino                0.06 -0.14  0.35  0.16
## Grade.4.Math.4s...Asian.or.Pacific.Islander        -0.05  0.02  0.91  0.13
## Grade.4.Math.4s...White                            -0.05 -0.01  0.08  0.91
## Grade.4.Math.4s...Multiracial                      -0.03  0.04  0.01  0.49
## Grade.4.Math.4s...Limited.English.Proficient       -0.03 -0.01  0.72 -0.05
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native  -0.04  0.01  0.13 -0.06
## Grade.5.ELA.4s...Black.or.African.American         -0.08 -0.05 -0.03  0.03
## Grade.5.ELA.4s...Hispanic.or.Latino                 0.07 -0.14  0.38  0.24
## Grade.5.ELA.4s...Asian.or.Pacific.Islander         -0.04  0.01  0.84  0.17
## Grade.5.ELA.4s...White                             -0.03  0.00  0.06  0.91
## Grade.5.ELA.4s...Multiracial                       -0.02  0.02 -0.03  0.40
## Grade.5.ELA.4s...Limited.English.Proficient         0.02 -0.03  0.22  0.00
## Grade.5.Math.4s...American.Indian.or.Alaska.Native -0.04  0.01  0.14 -0.06
## Grade.5.Math.4s...Black.or.African.American        -0.04 -0.05  0.00  0.01
## Grade.5.Math.4s...Hispanic.or.Latino                0.09 -0.15  0.36  0.19
## Grade.5.Math.4s...Asian.or.Pacific.Islander        -0.05  0.02  0.90  0.08
## Grade.5.Math.4s...White                            -0.04  0.00  0.07  0.91
## Grade.5.Math.4s...Multiracial                      -0.02  0.00 -0.03  0.38
## Grade.5.Math.4s...Limited.English.Proficient       -0.03  0.01  0.73 -0.08
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native   0.12 -0.10  0.06  0.05
## Grade.6.ELA.4s...Black.or.African.American          0.09  0.12 -0.06 -0.03
## Grade.6.ELA.4s...Hispanic.or.Latino                 0.73  0.09 -0.07 -0.02
## Grade.6.ELA.4s...Asian.or.Pacific.Islander          0.78  0.34  0.01  0.02
## Grade.6.ELA.4s...White                              0.43  0.76 -0.03  0.07
## Grade.6.ELA.4s...Multiracial                       -0.01  0.81  0.00  0.00
## Grade.6.ELA.4s...Limited.English.Proficient         0.34 -0.08 -0.02 -0.04
## Grade.6.Math.4s...American.Indian.or.Alaska.Native  0.09 -0.09  0.06  0.05
## Grade.6.Math.4s...Black.or.African.American         0.08  0.08 -0.04 -0.03
## Grade.6.Math.4s...Hispanic.or.Latino                0.72  0.06 -0.05 -0.03
## Grade.6.Math.4s...Asian.or.Pacific.Islander         0.82  0.30  0.01  0.01
## Grade.6.Math.4s...White                             0.41  0.76 -0.03  0.08
## Grade.6.Math.4s...Multiracial                       0.01  0.77  0.00  0.00
## Grade.6.Math.4s...Limited.English.Proficient        0.72 -0.05 -0.01 -0.02
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native   0.04 -0.03  0.05  0.05
## Grade.7.ELA.4s...Black.or.African.American          0.14  0.15 -0.05 -0.02
## Grade.7.ELA.4s...Hispanic.or.Latino                 0.72  0.07 -0.09 -0.05
## Grade.7.ELA.4s...Asian.or.Pacific.Islander          0.76  0.33  0.00  0.02
## Grade.7.ELA.4s...White                              0.41  0.77 -0.03  0.06
## Grade.7.ELA.4s...Multiracial                       -0.04  0.71  0.00 -0.03
## Grade.7.ELA.4s...Limited.English.Proficient         0.29  0.08 -0.01  0.00
## Grade.7.Math.4s...American.Indian.or.Alaska.Native  0.13 -0.04  0.06  0.06
## Grade.7.Math.4s...Black.or.African.American         0.12  0.12 -0.03 -0.02
## Grade.7.Math.4s...Hispanic.or.Latino                0.70  0.03 -0.07 -0.05
## Grade.7.Math.4s...Asian.or.Pacific.Islander         0.83  0.27  0.00  0.00
## Grade.7.Math.4s...White                             0.42  0.77 -0.03  0.05
## Grade.7.Math.4s...Multiracial                      -0.02  0.69  0.00 -0.03
## Grade.7.Math.4s...Limited.English.Proficient        0.59 -0.09 -0.03 -0.03
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native   0.17 -0.14  0.06  0.05
## Grade.8.ELA.4s...Black.or.African.American          0.12  0.10 -0.03 -0.04
## Grade.8.ELA.4s...Hispanic.or.Latino                 0.66  0.06 -0.09 -0.07
## Grade.8.ELA.4s...Asian.or.Pacific.Islander          0.75  0.35  0.00  0.02
## Grade.8.ELA.4s...White                              0.43  0.77 -0.03  0.05
## Grade.8.ELA.4s...Multiracial                       -0.06  0.63  0.00 -0.03
## Grade.8.ELA.4s...Limited.English.Proficient         0.12  0.03  0.01 -0.01
## Grade.8.Math.4s...American.Indian.or.Alaska.Native  0.35 -0.12  0.02  0.02
## Grade.8.Math.4s...Black.or.African.American         0.08  0.04  0.00 -0.03
## Grade.8.Math.4s...Hispanic.or.Latino                0.58 -0.05 -0.05 -0.06
## Grade.8.Math.4s...Asian.or.Pacific.Islander         0.74  0.26 -0.01 -0.02
## Grade.8.Math.4s...White                             0.43  0.63 -0.02  0.02
## Grade.8.Math.4s...Multiracial                      -0.04  0.64  0.01 -0.02
## Grade.8.Math.4s...Limited.English.Proficient        0.59 -0.09 -0.02 -0.03
##                                                      RC3   RC6     h2   u2
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native   0.04  0.01 0.0059 0.99
## Grade.3.ELA.4s...Black.or.African.American          0.67 -0.11 0.4705 0.53
## Grade.3.ELA.4s...Hispanic.or.Latino                 0.26 -0.43 0.3759 0.62
## Grade.3.ELA.4s...Asian.or.Pacific.Islander         -0.08  0.03 0.6561 0.34
## Grade.3.ELA.4s...White                             -0.08 -0.04 0.7619 0.24
## Grade.3.ELA.4s...Multiracial                        0.04 -0.01 0.3096 0.69
## Grade.3.ELA.4s...Limited.English.Proficient         0.01 -0.09 0.0932 0.91
## Grade.3.Math.4s...American.Indian.or.Alaska.Native  0.17  0.00 0.0358 0.96
## Grade.3.Math.4s...Black.or.African.American         0.78 -0.12 0.6264 0.37
## Grade.3.Math.4s...Hispanic.or.Latino                0.31 -0.50 0.4715 0.53
## Grade.3.Math.4s...Asian.or.Pacific.Islander        -0.11  0.06 0.8413 0.16
## Grade.3.Math.4s...White                            -0.09 -0.05 0.8155 0.18
## Grade.3.Math.4s...Multiracial                       0.01 -0.01 0.3088 0.69
## Grade.3.Math.4s...Limited.English.Proficient        0.00 -0.04 0.5211 0.48
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native   0.11  0.00 0.0455 0.95
## Grade.4.ELA.4s...Black.or.African.American          0.73 -0.14 0.5627 0.44
## Grade.4.ELA.4s...Hispanic.or.Latino                 0.19 -0.50 0.4851 0.51
## Grade.4.ELA.4s...Asian.or.Pacific.Islander         -0.09  0.03 0.7827 0.22
## Grade.4.ELA.4s...White                             -0.09 -0.04 0.8685 0.13
## Grade.4.ELA.4s...Multiracial                        0.04  0.02 0.2713 0.73
## Grade.4.ELA.4s...Limited.English.Proficient         0.01 -0.15 0.1537 0.85
## Grade.4.Math.4s...American.Indian.or.Alaska.Native  0.17  0.00 0.0615 0.94
## Grade.4.Math.4s...Black.or.African.American         0.81 -0.13 0.6835 0.32
## Grade.4.Math.4s...Hispanic.or.Latino                0.26 -0.51 0.4961 0.50
## Grade.4.Math.4s...Asian.or.Pacific.Islander        -0.10  0.05 0.8586 0.14
## Grade.4.Math.4s...White                            -0.10 -0.03 0.8515 0.15
## Grade.4.Math.4s...Multiracial                       0.09  0.02 0.2524 0.75
## Grade.4.Math.4s...Limited.English.Proficient       -0.06 -0.02 0.5257 0.47
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native   0.06  0.01 0.0248 0.98
## Grade.5.ELA.4s...Black.or.African.American          0.71 -0.11 0.5289 0.47
## Grade.5.ELA.4s...Hispanic.or.Latino                 0.14 -0.45 0.4427 0.56
## Grade.5.ELA.4s...Asian.or.Pacific.Islander         -0.10  0.05 0.7432 0.26
## Grade.5.ELA.4s...White                             -0.09 -0.03 0.8371 0.16
## Grade.5.ELA.4s...Multiracial                       -0.02  0.01 0.1621 0.84
## Grade.5.ELA.4s...Limited.English.Proficient         0.01 -0.14 0.0710 0.93
## Grade.5.Math.4s...American.Indian.or.Alaska.Native  0.07  0.01 0.0302 0.97
## Grade.5.Math.4s...Black.or.African.American         0.80 -0.11 0.6638 0.34
## Grade.5.Math.4s...Hispanic.or.Latino                0.19 -0.48 0.4614 0.54
## Grade.5.Math.4s...Asian.or.Pacific.Islander        -0.11  0.07 0.8349 0.17
## Grade.5.Math.4s...White                            -0.10 -0.03 0.8385 0.16
## Grade.5.Math.4s...Multiracial                       0.00 -0.01 0.1456 0.85
## Grade.5.Math.4s...Limited.English.Proficient       -0.06  0.03 0.5449 0.46
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native   0.14  0.75 0.6090 0.39
## Grade.6.ELA.4s...Black.or.African.American          0.65  0.27 0.5252 0.47
## Grade.6.ELA.4s...Hispanic.or.Latino                 0.09 -0.01 0.5484 0.45
## Grade.6.ELA.4s...Asian.or.Pacific.Islander         -0.05  0.15 0.7538 0.25
## Grade.6.ELA.4s...White                              0.00  0.01 0.7609 0.24
## Grade.6.ELA.4s...Multiracial                        0.04  0.02 0.6524 0.35
## Grade.6.ELA.4s...Limited.English.Proficient        -0.06 -0.06 0.1297 0.87
## Grade.6.Math.4s...American.Indian.or.Alaska.Native  0.15  0.74 0.5945 0.41
## Grade.6.Math.4s...Black.or.African.American         0.79  0.16 0.6627 0.34
## Grade.6.Math.4s...Hispanic.or.Latino                0.17 -0.07 0.5538 0.45
## Grade.6.Math.4s...Asian.or.Pacific.Islander        -0.07  0.14 0.7783 0.22
## Grade.6.Math.4s...White                             0.01  0.01 0.7578 0.24
## Grade.6.Math.4s...Multiracial                       0.06 -0.01 0.5943 0.41
## Grade.6.Math.4s...Limited.English.Proficient       -0.09  0.06 0.5338 0.47
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native   0.14  0.64 0.4371 0.56
## Grade.7.ELA.4s...Black.or.African.American          0.56  0.33 0.4726 0.53
## Grade.7.ELA.4s...Hispanic.or.Latino                 0.08  0.04 0.5430 0.46
## Grade.7.ELA.4s...Asian.or.Pacific.Islander         -0.05  0.17 0.7190 0.28
## Grade.7.ELA.4s...White                              0.02  0.01 0.7695 0.23
## Grade.7.ELA.4s...Multiracial                        0.01 -0.02 0.5115 0.49
## Grade.7.ELA.4s...Limited.English.Proficient        -0.03  0.01 0.0890 0.91
## Grade.7.Math.4s...American.Indian.or.Alaska.Native  0.10  0.62 0.4224 0.58
## Grade.7.Math.4s...Black.or.African.American         0.71  0.12 0.5510 0.45
## Grade.7.Math.4s...Hispanic.or.Latino                0.13 -0.04 0.5174 0.48
## Grade.7.Math.4s...Asian.or.Pacific.Islander        -0.07  0.14 0.7842 0.22
## Grade.7.Math.4s...White                             0.03  0.03 0.7820 0.22
## Grade.7.Math.4s...Multiracial                       0.00 -0.01 0.4805 0.52
## Grade.7.Math.4s...Limited.English.Proficient       -0.09  0.03 0.3715 0.63
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native   0.09  0.70 0.5573 0.44
## Grade.8.ELA.4s...Black.or.African.American          0.55  0.32 0.4365 0.56
## Grade.8.ELA.4s...Hispanic.or.Latino                 0.08  0.01 0.4653 0.53
## Grade.8.ELA.4s...Asian.or.Pacific.Islander         -0.04  0.16 0.7122 0.29
## Grade.8.ELA.4s...White                              0.02  0.02 0.7798 0.22
## Grade.8.ELA.4s...Multiracial                        0.00 -0.02 0.4046 0.60
## Grade.8.ELA.4s...Limited.English.Proficient         0.10  0.02 0.0249 0.98
## Grade.8.Math.4s...American.Indian.or.Alaska.Native -0.02  0.26 0.2024 0.80
## Grade.8.Math.4s...Black.or.African.American         0.55  0.07 0.3215 0.68
## Grade.8.Math.4s...Hispanic.or.Latino                0.10 -0.12 0.3713 0.63
## Grade.8.Math.4s...Asian.or.Pacific.Islander        -0.06  0.06 0.6142 0.39
## Grade.8.Math.4s...White                             0.02  0.01 0.5835 0.42
## Grade.8.Math.4s...Multiracial                       0.03 -0.02 0.4185 0.58
## Grade.8.Math.4s...Limited.English.Proficient       -0.08  0.04 0.3704 0.63
##                                                    com
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native  3.9
## Grade.3.ELA.4s...Black.or.African.American         1.1
## Grade.3.ELA.4s...Hispanic.or.Latino                3.2
## Grade.3.ELA.4s...Asian.or.Pacific.Islander         1.2
## Grade.3.ELA.4s...White                             1.0
## Grade.3.ELA.4s...Multiracial                       1.0
## Grade.3.ELA.4s...Limited.English.Proficient        1.3
## Grade.3.Math.4s...American.Indian.or.Alaska.Native 1.6
## Grade.3.Math.4s...Black.or.African.American        1.1
## Grade.3.Math.4s...Hispanic.or.Latino               2.8
## Grade.3.Math.4s...Asian.or.Pacific.Islander        1.1
## Grade.3.Math.4s...White                            1.0
## Grade.3.Math.4s...Multiracial                      1.0
## Grade.3.Math.4s...Limited.English.Proficient       1.0
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native  2.3
## Grade.4.ELA.4s...Black.or.African.American         1.1
## Grade.4.ELA.4s...Hispanic.or.Latino                2.8
## Grade.4.ELA.4s...Asian.or.Pacific.Islander         1.1
## Grade.4.ELA.4s...White                             1.0
## Grade.4.ELA.4s...Multiracial                       1.0
## Grade.4.ELA.4s...Limited.English.Proficient        1.4
## Grade.4.Math.4s...American.Indian.or.Alaska.Native 2.4
## Grade.4.Math.4s...Black.or.African.American        1.1
## Grade.4.Math.4s...Hispanic.or.Latino               2.8
## Grade.4.Math.4s...Asian.or.Pacific.Islander        1.1
## Grade.4.Math.4s...White                            1.0
## Grade.4.Math.4s...Multiracial                      1.1
## Grade.4.Math.4s...Limited.English.Proficient       1.0
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native  2.1
## Grade.5.ELA.4s...Black.or.African.American         1.1
## Grade.5.ELA.4s...Hispanic.or.Latino                3.0
## Grade.5.ELA.4s...Asian.or.Pacific.Islander         1.1
## Grade.5.ELA.4s...White                             1.0
## Grade.5.ELA.4s...Multiracial                       1.0
## Grade.5.ELA.4s...Limited.English.Proficient        1.8
## Grade.5.Math.4s...American.Indian.or.Alaska.Native 2.1
## Grade.5.Math.4s...Black.or.African.American        1.1
## Grade.5.Math.4s...Hispanic.or.Latino               2.9
## Grade.5.Math.4s...Asian.or.Pacific.Islander        1.1
## Grade.5.Math.4s...White                            1.0
## Grade.5.Math.4s...Multiracial                      1.0
## Grade.5.Math.4s...Limited.English.Proficient       1.0
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native  1.2
## Grade.6.ELA.4s...Black.or.African.American         1.5
## Grade.6.ELA.4s...Hispanic.or.Latino                1.1
## Grade.6.ELA.4s...Asian.or.Pacific.Islander         1.5
## Grade.6.ELA.4s...White                             1.6
## Grade.6.ELA.4s...Multiracial                       1.0
## Grade.6.ELA.4s...Limited.English.Proficient        1.3
## Grade.6.Math.4s...American.Indian.or.Alaska.Native 1.2
## Grade.6.Math.4s...Black.or.African.American        1.1
## Grade.6.Math.4s...Hispanic.or.Latino               1.2
## Grade.6.Math.4s...Asian.or.Pacific.Islander        1.3
## Grade.6.Math.4s...White                            1.6
## Grade.6.Math.4s...Multiracial                      1.0
## Grade.6.Math.4s...Limited.English.Proficient       1.1
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native  1.1
## Grade.7.ELA.4s...Black.or.African.American         1.9
## Grade.7.ELA.4s...Hispanic.or.Latino                1.1
## Grade.7.ELA.4s...Asian.or.Pacific.Islander         1.5
## Grade.7.ELA.4s...White                             1.5
## Grade.7.ELA.4s...Multiracial                       1.0
## Grade.7.ELA.4s...Limited.English.Proficient        1.2
## Grade.7.Math.4s...American.Indian.or.Alaska.Native 1.2
## Grade.7.Math.4s...Black.or.African.American        1.2
## Grade.7.Math.4s...Hispanic.or.Latino               1.1
## Grade.7.Math.4s...Asian.or.Pacific.Islander        1.3
## Grade.7.Math.4s...White                            1.6
## Grade.7.Math.4s...Multiracial                      1.0
## Grade.7.Math.4s...Limited.English.Proficient       1.1
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native  1.3
## Grade.8.ELA.4s...Black.or.African.American         1.8
## Grade.8.ELA.4s...Hispanic.or.Latino                1.1
## Grade.8.ELA.4s...Asian.or.Pacific.Islander         1.5
## Grade.8.ELA.4s...White                             1.6
## Grade.8.ELA.4s...Multiracial                       1.0
## Grade.8.ELA.4s...Limited.English.Proficient        2.2
## Grade.8.Math.4s...American.Indian.or.Alaska.Native 2.1
## Grade.8.Math.4s...Black.or.African.American        1.1
## Grade.8.Math.4s...Hispanic.or.Latino               1.2
## Grade.8.Math.4s...Asian.or.Pacific.Islander        1.3
## Grade.8.Math.4s...White                            1.8
## Grade.8.Math.4s...Multiracial                      1.0
## Grade.8.Math.4s...Limited.English.Proficient       1.1
## 
##                        RC1  RC5  RC2  RC4  RC3  RC6
## SS loadings           9.35 7.27 7.19 6.78 6.63 4.48
## Proportion Var        0.11 0.09 0.09 0.08 0.08 0.05
## Cumulative Var        0.11 0.20 0.28 0.36 0.44 0.50
## Proportion Explained  0.22 0.17 0.17 0.16 0.16 0.11
## Cumulative Proportion 0.22 0.40 0.57 0.73 0.89 1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 6 components are sufficient.
## 
## The root mean square of the residuals (RMSR) is  0.08 
##  with the empirical chi square  58234  with prob <  0 
## 
## Fit based upon off diagonal values = 0.86
print(pca_2b$loadings, cutoff=.44, sort=T)
## 
## Loadings:
##                                                    RC1    RC5    RC2   
## Grade.6.ELA.4s...Hispanic.or.Latino                 0.726              
## Grade.6.ELA.4s...Asian.or.Pacific.Islander          0.781              
## Grade.6.Math.4s...Hispanic.or.Latino                0.717              
## Grade.6.Math.4s...Asian.or.Pacific.Islander         0.816              
## Grade.6.Math.4s...Limited.English.Proficient        0.721              
## Grade.7.ELA.4s...Hispanic.or.Latino                 0.721              
## Grade.7.ELA.4s...Asian.or.Pacific.Islander          0.761              
## Grade.7.Math.4s...Hispanic.or.Latino                0.701              
## Grade.7.Math.4s...Asian.or.Pacific.Islander         0.829              
## Grade.7.Math.4s...Limited.English.Proficient        0.594              
## Grade.8.ELA.4s...Hispanic.or.Latino                 0.664              
## Grade.8.ELA.4s...Asian.or.Pacific.Islander          0.751              
## Grade.8.Math.4s...Hispanic.or.Latino                0.583              
## Grade.8.Math.4s...Asian.or.Pacific.Islander         0.735              
## Grade.8.Math.4s...Limited.English.Proficient        0.594              
## Grade.6.ELA.4s...White                                     0.757       
## Grade.6.ELA.4s...Multiracial                               0.806       
## Grade.6.Math.4s...White                                    0.762       
## Grade.6.Math.4s...Multiracial                              0.768       
## Grade.7.ELA.4s...White                                     0.774       
## Grade.7.ELA.4s...Multiracial                               0.713       
## Grade.7.Math.4s...White                                    0.773       
## Grade.7.Math.4s...Multiracial                              0.692       
## Grade.8.ELA.4s...White                                     0.769       
## Grade.8.ELA.4s...Multiracial                               0.632       
## Grade.8.Math.4s...White                                    0.630       
## Grade.8.Math.4s...Multiracial                              0.644       
## Grade.3.ELA.4s...Asian.or.Pacific.Islander                        0.776
## Grade.3.Math.4s...Asian.or.Pacific.Islander                       0.899
## Grade.3.Math.4s...Limited.English.Proficient                      0.717
## Grade.4.ELA.4s...Asian.or.Pacific.Islander                        0.856
## Grade.4.Math.4s...Asian.or.Pacific.Islander                       0.909
## Grade.4.Math.4s...Limited.English.Proficient                      0.720
## Grade.5.ELA.4s...Asian.or.Pacific.Islander                        0.836
## Grade.5.Math.4s...Asian.or.Pacific.Islander                       0.899
## Grade.5.Math.4s...Limited.English.Proficient                      0.730
## Grade.3.ELA.4s...White                                                 
## Grade.3.ELA.4s...Multiracial                                           
## Grade.3.Math.4s...White                                                
## Grade.3.Math.4s...Multiracial                                          
## Grade.4.ELA.4s...White                                                 
## Grade.4.ELA.4s...Multiracial                                           
## Grade.4.Math.4s...White                                                
## Grade.5.ELA.4s...White                                                 
## Grade.5.Math.4s...White                                                
## Grade.3.ELA.4s...Black.or.African.American                             
## Grade.3.Math.4s...Black.or.African.American                            
## Grade.4.ELA.4s...Black.or.African.American                             
## Grade.4.Math.4s...Black.or.African.American                            
## Grade.5.ELA.4s...Black.or.African.American                             
## Grade.5.Math.4s...Black.or.African.American                            
## Grade.6.ELA.4s...Black.or.African.American                             
## Grade.6.Math.4s...Black.or.African.American                            
## Grade.7.ELA.4s...Black.or.African.American                             
## Grade.7.Math.4s...Black.or.African.American                            
## Grade.8.ELA.4s...Black.or.African.American                             
## Grade.8.Math.4s...Black.or.African.American                            
## Grade.4.Math.4s...Hispanic.or.Latino                                   
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.6.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.7.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.3.ELA.4s...Hispanic.or.Latino                                    
## Grade.3.ELA.4s...Limited.English.Proficient                            
## Grade.3.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.3.Math.4s...Hispanic.or.Latino                                   
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.4.ELA.4s...Hispanic.or.Latino                                    
## Grade.4.ELA.4s...Limited.English.Proficient                            
## Grade.4.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.4.Math.4s...Multiracial                                          
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.5.ELA.4s...Hispanic.or.Latino                                    
## Grade.5.ELA.4s...Multiracial                                           
## Grade.5.ELA.4s...Limited.English.Proficient                            
## Grade.5.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.5.Math.4s...Hispanic.or.Latino                                   
## Grade.5.Math.4s...Multiracial                                          
## Grade.6.ELA.4s...Limited.English.Proficient                            
## Grade.7.ELA.4s...Limited.English.Proficient                            
## Grade.8.ELA.4s...Limited.English.Proficient                            
## Grade.8.Math.4s...American.Indian.or.Alaska.Native                     
##                                                    RC4    RC3    RC6   
## Grade.6.ELA.4s...Hispanic.or.Latino                                    
## Grade.6.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.6.Math.4s...Hispanic.or.Latino                                   
## Grade.6.Math.4s...Asian.or.Pacific.Islander                            
## Grade.6.Math.4s...Limited.English.Proficient                           
## Grade.7.ELA.4s...Hispanic.or.Latino                                    
## Grade.7.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.7.Math.4s...Hispanic.or.Latino                                   
## Grade.7.Math.4s...Asian.or.Pacific.Islander                            
## Grade.7.Math.4s...Limited.English.Proficient                           
## Grade.8.ELA.4s...Hispanic.or.Latino                                    
## Grade.8.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.8.Math.4s...Hispanic.or.Latino                                   
## Grade.8.Math.4s...Asian.or.Pacific.Islander                            
## Grade.8.Math.4s...Limited.English.Proficient                           
## Grade.6.ELA.4s...White                                                 
## Grade.6.ELA.4s...Multiracial                                           
## Grade.6.Math.4s...White                                                
## Grade.6.Math.4s...Multiracial                                          
## Grade.7.ELA.4s...White                                                 
## Grade.7.ELA.4s...Multiracial                                           
## Grade.7.Math.4s...White                                                
## Grade.7.Math.4s...Multiracial                                          
## Grade.8.ELA.4s...White                                                 
## Grade.8.ELA.4s...Multiracial                                           
## Grade.8.Math.4s...White                                                
## Grade.8.Math.4s...Multiracial                                          
## Grade.3.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.3.Math.4s...Asian.or.Pacific.Islander                            
## Grade.3.Math.4s...Limited.English.Proficient                           
## Grade.4.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.4.Math.4s...Asian.or.Pacific.Islander                            
## Grade.4.Math.4s...Limited.English.Proficient                           
## Grade.5.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.5.Math.4s...Asian.or.Pacific.Islander                            
## Grade.5.Math.4s...Limited.English.Proficient                           
## Grade.3.ELA.4s...White                              0.865              
## Grade.3.ELA.4s...Multiracial                        0.554              
## Grade.3.Math.4s...White                             0.893              
## Grade.3.Math.4s...Multiracial                       0.553              
## Grade.4.ELA.4s...White                              0.923              
## Grade.4.ELA.4s...Multiracial                        0.517              
## Grade.4.Math.4s...White                             0.913              
## Grade.5.ELA.4s...White                              0.908              
## Grade.5.Math.4s...White                             0.906              
## Grade.3.ELA.4s...Black.or.African.American                 0.670       
## Grade.3.Math.4s...Black.or.African.American                0.777       
## Grade.4.ELA.4s...Black.or.African.American                 0.730       
## Grade.4.Math.4s...Black.or.African.American                0.812       
## Grade.5.ELA.4s...Black.or.African.American                 0.711       
## Grade.5.Math.4s...Black.or.African.American                0.805       
## Grade.6.ELA.4s...Black.or.African.American                 0.652       
## Grade.6.Math.4s...Black.or.African.American                0.788       
## Grade.7.ELA.4s...Black.or.African.American                 0.565       
## Grade.7.Math.4s...Black.or.African.American                0.710       
## Grade.8.ELA.4s...Black.or.African.American                 0.555       
## Grade.8.Math.4s...Black.or.African.American                0.554       
## Grade.4.Math.4s...Hispanic.or.Latino                             -0.510
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native                 0.748
## Grade.6.Math.4s...American.Indian.or.Alaska.Native                0.742
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native                 0.641
## Grade.7.Math.4s...American.Indian.or.Alaska.Native                0.623
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native                 0.703
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.3.ELA.4s...Hispanic.or.Latino                                    
## Grade.3.ELA.4s...Limited.English.Proficient                            
## Grade.3.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.3.Math.4s...Hispanic.or.Latino                             -0.499
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.4.ELA.4s...Hispanic.or.Latino                              -0.495
## Grade.4.ELA.4s...Limited.English.Proficient                            
## Grade.4.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.4.Math.4s...Multiracial                       0.493              
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.5.ELA.4s...Hispanic.or.Latino                              -0.446
## Grade.5.ELA.4s...Multiracial                                           
## Grade.5.ELA.4s...Limited.English.Proficient                            
## Grade.5.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.5.Math.4s...Hispanic.or.Latino                             -0.480
## Grade.5.Math.4s...Multiracial                                          
## Grade.6.ELA.4s...Limited.English.Proficient                            
## Grade.7.ELA.4s...Limited.English.Proficient                            
## Grade.8.ELA.4s...Limited.English.Proficient                            
## Grade.8.Math.4s...American.Indian.or.Alaska.Native                     
## 
##                  RC1   RC5   RC2   RC4   RC3   RC6
## SS loadings    9.349 7.271 7.188 6.775 6.625 4.482
## Proportion Var 0.111 0.087 0.086 0.081 0.079 0.053
## Cumulative Var 0.111 0.198 0.283 0.364 0.443 0.496
#It seems that RC1 has Hispanic or Latino grouped with Asian or Pacitic Islander. Perhaps we can increase the groupings to see if more components would separate the grade and ethnicity for each variable that would make the component groupings make sense.

#increase components to 9, since 9 components had 62.2% of the data, which is within 60-80% variance that we should have.
pca_2b <- psych::principal(final, rotate="varimax", nfactors=9)

print(pca_2b$loadings, cutoff=.46, sort=T)
## 
## Loadings:
##                                                    RC5    RC1    RC2   
## Grade.6.ELA.4s...White                              0.764              
## Grade.6.ELA.4s...Multiracial                        0.826              
## Grade.6.Math.4s...White                             0.768              
## Grade.6.Math.4s...Multiracial                       0.782              
## Grade.7.ELA.4s...White                              0.780              
## Grade.7.ELA.4s...Multiracial                        0.729              
## Grade.7.Math.4s...White                             0.780              
## Grade.7.Math.4s...Multiracial                       0.708              
## Grade.8.ELA.4s...White                              0.776              
## Grade.8.ELA.4s...Multiracial                        0.646              
## Grade.8.Math.4s...White                             0.640              
## Grade.8.Math.4s...Multiracial                       0.659              
## Grade.6.ELA.4s...Asian.or.Pacific.Islander                 0.818       
## Grade.6.Math.4s...Asian.or.Pacific.Islander                0.861       
## Grade.6.Math.4s...Limited.English.Proficient               0.801       
## Grade.7.ELA.4s...Asian.or.Pacific.Islander                 0.780       
## Grade.7.Math.4s...Asian.or.Pacific.Islander                0.883       
## Grade.7.Math.4s...Limited.English.Proficient               0.719       
## Grade.8.ELA.4s...Asian.or.Pacific.Islander                 0.787       
## Grade.8.Math.4s...Asian.or.Pacific.Islander                0.821       
## Grade.8.Math.4s...Limited.English.Proficient               0.728       
## Grade.3.ELA.4s...Asian.or.Pacific.Islander                        0.793
## Grade.3.Math.4s...Asian.or.Pacific.Islander                       0.931
## Grade.3.Math.4s...Limited.English.Proficient                      0.710
## Grade.4.ELA.4s...Asian.or.Pacific.Islander                        0.872
## Grade.4.Math.4s...Asian.or.Pacific.Islander                       0.935
## Grade.4.Math.4s...Limited.English.Proficient                      0.718
## Grade.5.ELA.4s...Asian.or.Pacific.Islander                        0.869
## Grade.5.Math.4s...Asian.or.Pacific.Islander                       0.944
## Grade.5.Math.4s...Limited.English.Proficient                      0.756
## Grade.3.ELA.4s...White                                                 
## Grade.3.ELA.4s...Multiracial                                           
## Grade.3.Math.4s...White                                                
## Grade.3.Math.4s...Multiracial                                          
## Grade.4.ELA.4s...White                                                 
## Grade.4.ELA.4s...Multiracial                                           
## Grade.4.Math.4s...White                                                
## Grade.4.Math.4s...Multiracial                                          
## Grade.5.ELA.4s...White                                                 
## Grade.5.Math.4s...White                                                
## Grade.3.ELA.4s...Black.or.African.American                             
## Grade.3.Math.4s...Black.or.African.American                            
## Grade.4.ELA.4s...Black.or.African.American                             
## Grade.4.Math.4s...Black.or.African.American                            
## Grade.5.ELA.4s...Black.or.African.American                             
## Grade.5.Math.4s...Black.or.African.American                            
## Grade.6.ELA.4s...Black.or.African.American                             
## Grade.6.Math.4s...Black.or.African.American                            
## Grade.7.ELA.4s...Black.or.African.American                             
## Grade.7.Math.4s...Black.or.African.American                            
## Grade.8.ELA.4s...Black.or.African.American                             
## Grade.8.Math.4s...Black.or.African.American                            
## Grade.6.ELA.4s...Hispanic.or.Latino                                    
## Grade.6.Math.4s...Hispanic.or.Latino                                   
## Grade.7.ELA.4s...Hispanic.or.Latino                                    
## Grade.7.Math.4s...Hispanic.or.Latino                                   
## Grade.8.ELA.4s...Hispanic.or.Latino                                    
## Grade.8.Math.4s...Hispanic.or.Latino                                   
## Grade.3.ELA.4s...Hispanic.or.Latino                                    
## Grade.3.Math.4s...Hispanic.or.Latino                                   
## Grade.4.ELA.4s...Hispanic.or.Latino                                    
## Grade.4.Math.4s...Hispanic.or.Latino                                   
## Grade.5.ELA.4s...Hispanic.or.Latino                                    
## Grade.5.Math.4s...Hispanic.or.Latino                                   
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.6.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.7.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.4.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.5.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.3.ELA.4s...Limited.English.Proficient                            
## Grade.3.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.4.ELA.4s...Limited.English.Proficient                            
## Grade.5.ELA.4s...Multiracial                                           
## Grade.5.ELA.4s...Limited.English.Proficient                            
## Grade.5.Math.4s...Multiracial                                          
## Grade.6.ELA.4s...Limited.English.Proficient                            
## Grade.7.ELA.4s...Limited.English.Proficient                            
## Grade.8.ELA.4s...Limited.English.Proficient                            
## Grade.8.Math.4s...American.Indian.or.Alaska.Native                     
##                                                    RC4    RC3    RC9   
## Grade.6.ELA.4s...White                                                 
## Grade.6.ELA.4s...Multiracial                                           
## Grade.6.Math.4s...White                                                
## Grade.6.Math.4s...Multiracial                                          
## Grade.7.ELA.4s...White                                                 
## Grade.7.ELA.4s...Multiracial                                           
## Grade.7.Math.4s...White                                                
## Grade.7.Math.4s...Multiracial                                          
## Grade.8.ELA.4s...White                                                 
## Grade.8.ELA.4s...Multiracial                                           
## Grade.8.Math.4s...White                                                
## Grade.8.Math.4s...Multiracial                                          
## Grade.6.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.6.Math.4s...Asian.or.Pacific.Islander                            
## Grade.6.Math.4s...Limited.English.Proficient                           
## Grade.7.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.7.Math.4s...Asian.or.Pacific.Islander                            
## Grade.7.Math.4s...Limited.English.Proficient                           
## Grade.8.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.8.Math.4s...Asian.or.Pacific.Islander                            
## Grade.8.Math.4s...Limited.English.Proficient                           
## Grade.3.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.3.Math.4s...Asian.or.Pacific.Islander                            
## Grade.3.Math.4s...Limited.English.Proficient                           
## Grade.4.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.4.Math.4s...Asian.or.Pacific.Islander                            
## Grade.4.Math.4s...Limited.English.Proficient                           
## Grade.5.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.5.Math.4s...Asian.or.Pacific.Islander                            
## Grade.5.Math.4s...Limited.English.Proficient                           
## Grade.3.ELA.4s...White                              0.864              
## Grade.3.ELA.4s...Multiracial                        0.560              
## Grade.3.Math.4s...White                             0.891              
## Grade.3.Math.4s...Multiracial                       0.559              
## Grade.4.ELA.4s...White                              0.922              
## Grade.4.ELA.4s...Multiracial                        0.527              
## Grade.4.Math.4s...White                             0.912              
## Grade.4.Math.4s...Multiracial                       0.502              
## Grade.5.ELA.4s...White                              0.909              
## Grade.5.Math.4s...White                             0.907              
## Grade.3.ELA.4s...Black.or.African.American                 0.702       
## Grade.3.Math.4s...Black.or.African.American                0.811       
## Grade.4.ELA.4s...Black.or.African.American                 0.765       
## Grade.4.Math.4s...Black.or.African.American                0.844       
## Grade.5.ELA.4s...Black.or.African.American                 0.745       
## Grade.5.Math.4s...Black.or.African.American                0.820       
## Grade.6.ELA.4s...Black.or.African.American                 0.656       
## Grade.6.Math.4s...Black.or.African.American                0.790       
## Grade.7.ELA.4s...Black.or.African.American                 0.558       
## Grade.7.Math.4s...Black.or.African.American                0.719       
## Grade.8.ELA.4s...Black.or.African.American                 0.536       
## Grade.8.Math.4s...Black.or.African.American                0.550       
## Grade.6.ELA.4s...Hispanic.or.Latino                               0.839
## Grade.6.Math.4s...Hispanic.or.Latino                              0.851
## Grade.7.ELA.4s...Hispanic.or.Latino                               0.850
## Grade.7.Math.4s...Hispanic.or.Latino                              0.835
## Grade.8.ELA.4s...Hispanic.or.Latino                               0.850
## Grade.8.Math.4s...Hispanic.or.Latino                              0.711
## Grade.3.ELA.4s...Hispanic.or.Latino                                    
## Grade.3.Math.4s...Hispanic.or.Latino                                   
## Grade.4.ELA.4s...Hispanic.or.Latino                                    
## Grade.4.Math.4s...Hispanic.or.Latino                                   
## Grade.5.ELA.4s...Hispanic.or.Latino                                    
## Grade.5.Math.4s...Hispanic.or.Latino                                   
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.6.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.7.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.4.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.5.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.3.ELA.4s...Limited.English.Proficient                            
## Grade.3.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.4.ELA.4s...Limited.English.Proficient                            
## Grade.5.ELA.4s...Multiracial                                           
## Grade.5.ELA.4s...Limited.English.Proficient                            
## Grade.5.Math.4s...Multiracial                                          
## Grade.6.ELA.4s...Limited.English.Proficient                            
## Grade.7.ELA.4s...Limited.English.Proficient                            
## Grade.8.ELA.4s...Limited.English.Proficient                            
## Grade.8.Math.4s...American.Indian.or.Alaska.Native                     
##                                                    RC7    RC6    RC8   
## Grade.6.ELA.4s...White                                                 
## Grade.6.ELA.4s...Multiracial                                           
## Grade.6.Math.4s...White                                                
## Grade.6.Math.4s...Multiracial                                          
## Grade.7.ELA.4s...White                                                 
## Grade.7.ELA.4s...Multiracial                                           
## Grade.7.Math.4s...White                                                
## Grade.7.Math.4s...Multiracial                                          
## Grade.8.ELA.4s...White                                                 
## Grade.8.ELA.4s...Multiracial                                           
## Grade.8.Math.4s...White                                                
## Grade.8.Math.4s...Multiracial                                          
## Grade.6.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.6.Math.4s...Asian.or.Pacific.Islander                            
## Grade.6.Math.4s...Limited.English.Proficient                           
## Grade.7.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.7.Math.4s...Asian.or.Pacific.Islander                            
## Grade.7.Math.4s...Limited.English.Proficient                           
## Grade.8.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.8.Math.4s...Asian.or.Pacific.Islander                            
## Grade.8.Math.4s...Limited.English.Proficient                           
## Grade.3.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.3.Math.4s...Asian.or.Pacific.Islander                            
## Grade.3.Math.4s...Limited.English.Proficient                           
## Grade.4.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.4.Math.4s...Asian.or.Pacific.Islander                            
## Grade.4.Math.4s...Limited.English.Proficient                           
## Grade.5.ELA.4s...Asian.or.Pacific.Islander                             
## Grade.5.Math.4s...Asian.or.Pacific.Islander                            
## Grade.5.Math.4s...Limited.English.Proficient                           
## Grade.3.ELA.4s...White                                                 
## Grade.3.ELA.4s...Multiracial                                           
## Grade.3.Math.4s...White                                                
## Grade.3.Math.4s...Multiracial                                          
## Grade.4.ELA.4s...White                                                 
## Grade.4.ELA.4s...Multiracial                                           
## Grade.4.Math.4s...White                                                
## Grade.4.Math.4s...Multiracial                                          
## Grade.5.ELA.4s...White                                                 
## Grade.5.Math.4s...White                                                
## Grade.3.ELA.4s...Black.or.African.American                             
## Grade.3.Math.4s...Black.or.African.American                            
## Grade.4.ELA.4s...Black.or.African.American                             
## Grade.4.Math.4s...Black.or.African.American                            
## Grade.5.ELA.4s...Black.or.African.American                             
## Grade.5.Math.4s...Black.or.African.American                            
## Grade.6.ELA.4s...Black.or.African.American                             
## Grade.6.Math.4s...Black.or.African.American                            
## Grade.7.ELA.4s...Black.or.African.American                             
## Grade.7.Math.4s...Black.or.African.American                            
## Grade.8.ELA.4s...Black.or.African.American                             
## Grade.8.Math.4s...Black.or.African.American                            
## Grade.6.ELA.4s...Hispanic.or.Latino                                    
## Grade.6.Math.4s...Hispanic.or.Latino                                   
## Grade.7.ELA.4s...Hispanic.or.Latino                                    
## Grade.7.Math.4s...Hispanic.or.Latino                                   
## Grade.8.ELA.4s...Hispanic.or.Latino                                    
## Grade.8.Math.4s...Hispanic.or.Latino                                   
## Grade.3.ELA.4s...Hispanic.or.Latino                 0.733              
## Grade.3.Math.4s...Hispanic.or.Latino                0.839              
## Grade.4.ELA.4s...Hispanic.or.Latino                 0.867              
## Grade.4.Math.4s...Hispanic.or.Latino                0.884              
## Grade.5.ELA.4s...Hispanic.or.Latino                 0.779              
## Grade.5.Math.4s...Hispanic.or.Latino                0.832              
## Grade.6.ELA.4s...American.Indian.or.Alaska.Native          0.917       
## Grade.6.Math.4s...American.Indian.or.Alaska.Native         0.906       
## Grade.7.ELA.4s...American.Indian.or.Alaska.Native          0.790       
## Grade.7.Math.4s...American.Indian.or.Alaska.Native         0.801       
## Grade.8.ELA.4s...American.Indian.or.Alaska.Native          0.876       
## Grade.4.ELA.4s...American.Indian.or.Alaska.Native                 0.930
## Grade.4.Math.4s...American.Indian.or.Alaska.Native                0.919
## Grade.5.ELA.4s...American.Indian.or.Alaska.Native                 0.848
## Grade.5.Math.4s...American.Indian.or.Alaska.Native                0.905
## Grade.3.ELA.4s...American.Indian.or.Alaska.Native                      
## Grade.3.ELA.4s...Limited.English.Proficient                            
## Grade.3.Math.4s...American.Indian.or.Alaska.Native                     
## Grade.4.ELA.4s...Limited.English.Proficient                            
## Grade.5.ELA.4s...Multiracial                                           
## Grade.5.ELA.4s...Limited.English.Proficient                            
## Grade.5.Math.4s...Multiracial                                          
## Grade.6.ELA.4s...Limited.English.Proficient                            
## Grade.7.ELA.4s...Limited.English.Proficient                            
## Grade.8.ELA.4s...Limited.English.Proficient                            
## Grade.8.Math.4s...American.Indian.or.Alaska.Native                     
## 
##                  RC5   RC1   RC2   RC4   RC3   RC9   RC7   RC6   RC8
## SS loadings    7.378 7.015 6.711 6.637 6.343 5.729 4.723 4.153 3.587
## Proportion Var 0.088 0.084 0.080 0.079 0.076 0.068 0.056 0.049 0.043
## Cumulative Var 0.088 0.171 0.251 0.330 0.406 0.474 0.530 0.580 0.622
#ensure that varimax was the appropriate rotation.
round(cor(pca_2b$scores),2)
##     RC5 RC1 RC2 RC4 RC3 RC9 RC7 RC6 RC8
## RC5   1   0   0   0   0   0   0   0   0
## RC1   0   1   0   0   0   0   0   0   0
## RC2   0   0   1   0   0   0   0   0   0
## RC4   0   0   0   1   0   0   0   0   0
## RC3   0   0   0   0   1   0   0   0   0
## RC9   0   0   0   0   0   1   0   0   0
## RC7   0   0   0   0   0   0   1   0   0
## RC6   0   0   0   0   0   0   0   1   0
## RC8   0   0   0   0   0   0   0   0   1

Factor Analysis

knitr::include_graphics("Factor_Analysis_Intro.png")

Exploratory Factor Analysis: Similar to PCA In a regression model, have a lot of multicollinearity from the correlations and VIF, but want to keep all those variables in there because they are important to you. So will try a factor analysis to reduce them down while reducing the multicollinearity. Then determine the number of factors, the name for those factors, establish relationship from the loadings.

Confirmatory Factor Analysis: May or may not have a definitive number of components, can you establish a theory of your own to determine the number of components. We’ve established a theory from exploratory factor analysis, will now look at indirect and direct variables. Taking the variables of those components and seeing if there are other variables that provide a direct and in-direct relationships to our outcomes variables.

Ex) Journal Article already published, trying to mimic relationship from previous research to match your own use case of principal components derived from analysis.

#look at factor analysis, see if 4 components is still a good model to use
#simpliest way to drop a variable is to set it equal to null
fit = factanal(hbatReduced, 4)
#.51 takes out cross loading
print(fit$loadings, cutoff=.51, sort=T)
## 
## Loadings:
##                            Factor1 Factor2 Factor3 Factor4
## X9 - Complaint Resolution   0.884                         
## X16 - Order & Billing       0.794                         
## X18 - Delivery Speed        0.928                         
## X7 - E-Commerce Activities          0.793                 
## X10 - Advertising                   0.521                 
## X12 - Salesforce Image              0.974                 
## X8 - Technical Support                      0.872         
## X14 - Warranty & Claims                     0.894         
## X6 - Product Quality                                0.557 
## X11 - Product Line                                  0.856 
## X13 - Competitive Pricing                          -0.514 
## 
##                Factor1 Factor2 Factor3 Factor4
## SS loadings      2.592   1.977   1.638   1.423
## Proportion Var   0.236   0.180   0.149   0.129
## Cumulative Var   0.236   0.415   0.564   0.694

Comparison between PCA and Factor Analysis

knitr::include_graphics("Factor_Analysis_Comparison.png")

Cumulative variance is a lot smaller on the Common Factor Analysis than PCA. Why? PCA includes all variance (unique, error, and common shared variance).

In Common Factor Analysis, it only uses the common shared variance.

If you can assume or understand from the domain(error and unique variance), use PCA If not known, use Factor Analysis.